rrsnider
12-15-2001, 07:15 PM
Can someone tell me how to pass a variable to a PHP page. I am converting an ASP site to PHP. I have the following hyper link in my script but $ID does not have a value when it gets to the linked page. Do I need something in the destination page to retrieve the value ?
<a href="updateAutomobile.php?id=$ID">
Thanks
allending
12-15-2001, 08:18 PM
<a href="updateAutomobile.php?id=$ID">
A walkthrough:
you have this link on a page. when someone clicks on it, he will go to updateAutomobile.php , and updateAutomobile.php will now have the variable $id (small case) (or in php 4.1 $_GET["id"] :) ) available to it.
What $id 's value is is whatever was $ID (upper case) 's value when the user clicked on the link.
So if you dont want $id to be empty, $ID should be assigned the value for whatever you want it to be in the page where the hyperlink is , and before the hyperlink.
tetra
12-16-2001, 01:34 AM
rrsnider is correct but perhaps some more clarity will help. I think your issue may be simply that you didn't realise that php variables are case sensitive.
I presume your intention is to dynamically generate a link like
<a href="updateAutomobile.php?id=101">
That will make $id = 101 on the following page. It makes no difference if the 101 was hardcoded in the html or was the echoed value of $ID or any other variable.
It would be a good idea for you to check the latest release notes at php.net. As rrsnider eluded to, the recommended way of doing this in future is not to use the automatic get variables into local variables feature (register_globals = on) because of security issues. You can start using close to the recommended way even if you don't have php 4.1.0 although you will need to use the old array names like $HTTP_GET_VARS etc.
Ross
rrsnider
12-16-2001, 01:13 PM
Yes, you're correct. I finally figured out it was case sensitive.