Re: Filling Forms with $variables
| From: | Lars Torben Wilson | Date: | Wed, 13 Feb 2002 22:10:25 +0000 |
| Subject: | Re: Filling Forms with $variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84668@lists.php.net to get a copy of this message | ||
On Wed, 2002-02-13 at 13:56, Steven Walker wrote:
> Hi,
>
> I'm having trouble setting the value of form elements using variable
> values. For example:
>
> <?$name = "Steven Walker"?>
> <form name="form1" method="post" action="infocollect.php">
> <input type="text" name="name" value=<?echo
> "$name";?>>
> </form>
>
> In the browser, the name field is only filled with "Steven", and drops
> off everything after the space. If I echo $name outside of the form it
> prints fine.
>
> Any help would be really appreciated. Thanks!
Always quote your HTML attributes. Your code should read:
<? $name = "Steven Walker"; ?>
<form name="form1" method="post" action="infocollect.php">
<input type="text" name="name" value="<?echo $name;?>">
</form>
Cheers,
Torben
--
Torben Wilson <torben@php.net>
http://www.thebuttlesschaps.com
http://www.hybrid17.com
http://www.inflatableeye.com
+1.604.709.0506