Jump to content


Photo

Passing Vars over URL


  • Please log in to reply
2 replies to this topic

#1 deaf_jupiter

deaf_jupiter
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 October 2006 - 11:59 AM

Hi,

I came up this problem today:
I tried to pass a variable to a script creating a URL like:

article.php?id=25

Unfortunately it appears $id is quite empty. Is there some setting I need to alter?
It used to work in the past (php4 that is).
Also, I don't have great access to the settings so is there also a workaround besides changing the ini file?

Thank you in advance!

#2 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 13 October 2006 - 12:04 PM

now the query string is parsed into "SUPERGLOBALS"

The ?GET query string can be accessed with the SuperGlobal $_GET (Array)

eg.

<?php
$id = $_GET["id"];
echo $id;
?>

This was changed because from earlier versions of PHP for security and performance concerns. POST vars are now stored in $_POST :)
hth..

NOTE: you can also turn on the 'old skool' methods in php.ini

#3 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 13 October 2006 - 12:05 PM

register_globals is (rightly) turned off in your PHP.ini file - and should remain that way.

to get the contents of id in the URL, use $_GET['id']

edit: beat me to it :)
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users