4.2 passing varibles

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
riley
Forum Commoner
Posts: 45
Joined: Thu May 02, 2002 6:31 pm

4.2 passing varibles

Post 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?
User avatar
pHaZed
Forum Commoner
Posts: 28
Joined: Wed May 01, 2002 2:44 am
Location: Sydney -AU

Post 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
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
User avatar
riley
Forum Commoner
Posts: 45
Joined: Thu May 02, 2002 6:31 pm

Post 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!
User avatar
chiefmonkey
Forum Commoner
Posts: 25
Joined: Sat Apr 20, 2002 5:21 am
Location: Glasgow UK

Post 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
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
gastonlm
Forum Commoner
Posts: 26
Joined: Tue May 07, 2002 10:19 am
Location: Buenos Aires, Argentina
Contact:

Post 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?
Post Reply