Page 1 of 1

Passing variables in the URL

Posted: Sun Jun 01, 2003 6:37 am
by redhair
[Admin Edit: moved from the register globals sticky]

example:
i'm using a link in my page like this "index.php?action=login"

With my 'old' php, the page would just load(again) when the link is clicked but i echo the login part.

like

Code: Select all

<?php

if ($action=="login") {print "allthatshouldlooklikealogin";}

?>
but snif...with the new php version i get the same page loaded, but not with the loginpart echoo'd.

does anybody have a clue? :oops:

Posted: Sun Jun 01, 2003 9:13 am
by twigletmac
Did you read through all of Before Post Read: Concerning Passing Variables in PHP 4.2+? 'cause the answer is in there. Basically you need to start using the $_GET array for information coming from the query string, e.g.:

Code: Select all

if (isset($_GET['action']) && $_GET['action'] == 'login') {
    echo 'there we go';
}
Mac

Posted: Sun Jun 01, 2003 11:24 am
by redhair
Thanks Mac....i did read through it, but i was hoping there would be another option left then adjusting the code. Cause that always worked...and i have numerous scripts that i'd have to adjust now.
Then again..it will force me to learn to write it the right way. :!:

Posted: Sun Jun 01, 2003 1:25 pm
by AVATAr
you can turn register_globals off in your php.ini, but its a security issue...

Posted: Sun Jun 01, 2003 1:40 pm
by twigletmac
AVATAr wrote:you can turn register_globals off in your php.ini, but its a security issue...
More than that, it's deprecated so it's not going to be an option forever.

Mac

Posted: Sun Jun 01, 2003 3:50 pm
by AVATAr
that too... jeje :D