Page 1 of 1
4.2 passing varibles
Posted: Fri May 03, 2002 8:14 am
by riley
I am having trouble passing varibles from page to page in ver 4.2 I am using the exact same scripts as with previous versions, but keep getting the error:
Notice: Undefined variable:
Any thoughts?
Posted: Fri May 03, 2002 8:28 am
by pHaZed
execute phpinfo();
make sure ur new ini file is correct
i friend was having the same problem with 4.2
umm also
u can put the error reporting level to E_ALL
Posted: Fri May 03, 2002 8:33 am
by jason
riley: Remember, in PHP 4.2, the php.ini setting register_globals is off by default.
I suggest changing the setting from off to on in your php.ini file.
However, I also recommend using $_POST and $_GET
So before, if you had a variable passed from a form called $username, you would use
$_GET['username'] for forms passed via get and $_POST['usrname'] for forms passed via post.
Posted: Fri May 03, 2002 9:48 am
by riley
That worked! Thanks!
Can you explain why you would recommend using $_POST and $_GET. It works using just the varible name. Is there an advantage? Just for my education.
Thanks!
Posted: Fri May 03, 2002 10:07 am
by chiefmonkey
riley wrote:That worked! Thanks!
Can you explain why you would recommend using $_POST and $_GET. It works using just the varible name. Is there an advantage? Just for my education.
Thanks!
As of PHP 4.1.2 $HTTP_***_VARS['var'] is not a global variable unless you declare it as one, whereas $_POST is global by default
George
Posted: Fri May 03, 2002 11:00 am
by jason
riley: Also, using $_GET and $_POST force you to write more secure code. Check out
http://www.phpadvisory.com for more information on security.
Posted: Tue May 07, 2002 10:19 am
by gastonlm
I read the replies because I have the same problem(undefined variables message).I changed the php.ini file but I still have the problem in a page where the variable hasn't been used before. Could it be the problem? I didn't restarted windows but I don't think that it's necesary. Could you help me?