More PHP problems

SpaceshipSpaceship
SpaceshipSpaceship
NamecheapNamecheap
Watch

TwiztedFake

Established Member
Impact
1
I am attempting to write a control panel area for a site I'm working on for myself . This is my first attempt at coding an entire site from scratch and has been a great learning experience so far thanks to the members here at NP.

Anyways here is my current problem. I want to pass a variable through the url to another page which I thought would be no problem but I can't get it to work. Actually its 2 variables the first of which works fine without any problems.

Current Example URL is : http://www.kmcustoms.com/greenup/cp.php?id=edit_article&cid=?

id=edit_article is the variable that tells it which template to get, this works fine.
cid=?, The ? is suppose to be replaced by the id for the article stored in the database. It does create the link correct or should I say how I told it to. If that is the correct way to setup the url then I know my problem is on the edit_article page.

Now in the edit_article code I'm using this to get the variable info.
$id = $_REQUEST["cid"];

when I run it I don't get any of the information for the article with the given variable. Help Please!

*Updated*
Never mind I got it fixed. I was defining data for the output as ex: $row["title"] but hadn't defined what $row was. Still correct me if there is a better way to do this than I posted above.
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Could you post that section of the code please.

iNod.
 
0
Close
add this to a php.ini to the directory of your .php files:

register_globals = on

That will make variables sendable easier through the header link. You don't even have to do anything with the variable on the page, just use $id whereever you want it.

If you don't have a php.ini file, just make one in notepad with the text "register_globals = on" (without quotes) and save it as "php.ini" (without quotes).

Hope this helped :).
 
0
Close
Already fixed the problem but thanks anyways.
 
0
Close
I was telling you a better way of doing it.
 
0
Close
TwiztedFake said:
I am attempting to write a control panel area for a site I'm working on for myself . This is my first attempt at coding an entire site from scratch and has been a great learning experience so far thanks to the members here at NP.

Anyways here is my current problem. I want to pass a variable through the url to another page which I thought would be no problem but I can't get it to work. Actually its 2 variables the first of which works fine without any problems.

Current Example URL is : http://www.kmcustoms.com/greenup/cp.php?id=edit_article&cid=?

id=edit_article is the variable that tells it which template to get, this works fine.
cid=?, The ? is suppose to be replaced by the id for the article stored in the database. It does create the link correct or should I say how I told it to. If that is the correct way to setup the url then I know my problem is on the edit_article page.

Now in the edit_article code I'm using this to get the variable info.
$id = $_REQUEST["cid"];

when I run it I don't get any of the information for the article with the given variable. Help Please!

*Updated*
Never mind I got it fixed. I was defining data for the output as ex: $row["title"] but hadn't defined what $row was. Still correct me if there is a better way to do this than I posted above.


Don't use $_REQUEST

USE $_POST/$_GET

Security problem.
 
0
Close
Palyriot said:
I was telling you a better way of doing it.

Enabling register_globals is certainly not the best way to do it. In fact it is now advised that it be turned off (php 5 comes with it disabled by default wheres 4.X had it enabled).
 
0
Close
axilant said:
Don't use $_REQUEST

USE $_POST/$_GET

Security problem.

Didn't know that I'll have to change it. This is the only place I'm using $_REQUEST, since I'm passing it through the URL I'd have to use $_GET, correct.
 
0
Close
filth said:
Enabling register_globals is certainly not the best way to do it. In fact it is now advised that it be turned off (php 5 comes with it disabled by default wheres 4.X had it enabled).

Register_Globals is a major security issue and almost every host has it turned off. I DO NOT reccommand you turn it back on.

iNod.
 
0
Close
oh, I didn't know about this. Thank you. Is it only an issue because users can change variables?
 
0
Close
(IMO) it is better to specify $_GET rather than $_REQUEST, $_REQUEST is good if you are making it so it can be passed by _POST OR _GET but if u are strictly using ?xxx=xxx in the URL it should be done $_GET, just a thought
 
0
Close
Palyriot said:
oh, I didn't know about this. Thank you. Is it only an issue because users can change variables?

No there are many issues regarding it, 1 such other issue is people got lazy and did not check the data that was being passed and just assumed it was safe as register_globals was on.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back