Page 1 of 1

Help with a line of code

Posted: Fri Mar 21, 2003 8:57 am
by nigma
Hey, I am donering why this line of code:

echo("Apreciated person #$c: <input type=\"text\" name=fname$c value={$_POST['fname'.$c]}><br><br>");

prints only the first word what was entered in field fname on the previous input box?

Anyone know how to correct this problem so that this input box will display all text that was written in the previous input box?

Thanks for all help and advice provided.

Posted: Fri Mar 21, 2003 9:02 am
by twigletmac
You need to put quotes around your value attribute (or better yet all attributes) and then this won't happen:

Code: Select all

echo 'Apreciated person #'.$c.': <input type="text" name="fname'.$c.'" value="'.$_POST['fname'.$c].'" /><br /><br />';
If you don't put those double quotes in you get something like this produced:

Code: Select all

&lt;input type="text" name=fname1 value=something or other&gt;
and the browser has no idea that ' or other' have anything to do with the value, whereas it does if you have:

Code: Select all

&lt;input type="text" name="fname1" value="something or other"&gt;
Mac

Posted: Fri Mar 21, 2003 9:08 am
by nigma
That didn't work either. I have asked about this before and have recieved serveral ideas but all didn't work. So I dont know what is going on.

Posted: Fri Mar 21, 2003 9:11 am
by twigletmac
Have you tried just using of code like:

Code: Select all

<input type="text" name="fname1" value="something or other">
with all the values hardcoded in to see if that works?
Mac

Posted: Fri Mar 21, 2003 9:32 am
by nigma
Hmm.. I will check that out. If it works does that mean I have a problem with a setting in like php.ini or another configuration file?

Posted: Fri Mar 21, 2003 9:34 am
by twigletmac
If it works it may be that there is an issue in the code that posts the variables to this page.

Mac

Posted: Fri Mar 21, 2003 1:42 pm
by net7
echo "Apreciated person #{$c}: <input type=\"text\" name=fname{$c} value={$_POST['fname{$c}']}><br><br>";