Hidden field problem

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
vigour
Forum Newbie
Posts: 18
Joined: Thu Sep 29, 2005 2:04 am

Hidden field problem

Post by vigour »

I have a textfield in a form and the name of the textfield is textfieldName4

If I type 'myroadname' in the textfield everything works fine. But if I type 'myroadname 2A' I only get 'myroadname' left when I recieve the value on the other page. Everything after the space seems to just dissapear. Here is the code that I use for sending the hidden field.

Code: Select all

echo'<input type="hidden" name="value5" value='.$_POST['textfieldName4'].'>';
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

The problem is that there are no quotes around the value in the hidden field:

Code: Select all

echo'<input type="hidden" name="value5" value='.$_POST['textfieldName4'].'>';
should be

Code: Select all

echo'<input type="hidden" name="value5" value="'.$_POST['textfieldName4'].'">';
See the double quotes after the = sign and before the final > sign as you have done correctly for the type attribute and the name attribute.
Post Reply