Passing variables in the URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Passing variables in the URL

Post 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:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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. :!:
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

you can turn register_globals off in your php.ini, but its a security issue...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

that too... jeje :D
Post Reply