[SOLVED] Losing Variable from Form

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
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

[SOLVED] Losing Variable from Form

Post by lazersam »

Hi
I am passing a variable from a form to a php handler but when I use

Code: Select all

$first_name = $_POSTї'first_name'];
the variable is lost! If I leave out the $_POST code I can retain the variable. Does anyone know why this is so? I have other form handlers that are written the same but work OK.

Larry.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

What happens if you do a var_dump($_POST); ?

Does the first_name get displayed ? If not (the array is empty) please check the form is sending POST not GET.

Please give us more specific information (such as the form definition) in order that we can try to help you. The more "consise" information you give the easier it is for us to help you.

At a guess I would say it works leaving the $_POST because you have register_globals ON. Loads of posts on this so I will just say this is a bad idea.

Regards
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

Thanks - you are right! I forget to method="POST" in form :)

Thanks for your help.

Larry
Post Reply