oLraX oLraX - 1 year ago 55
PHP Question

Can't read space as default values in input text

I have some problem with entering default values in an input text form.
For example if the default value is "Hello World", the input field will only show "Hello."
It only accepts the first word. Is there something that I can do to accept the whole string?

<input type='text' name='prod_name' size='30' value=<?=$prname?> />

Answer Source

You need to put quotes around your value attribute

<input type='text' name='prod_name' size='30' value='<?=$prname?>' />

Notice, a $prname value of "Hello World" would yield this:

<input type='text' name='prod_name' size='30' value=Hello World> />

In which case the HTML thinks your input value is "Hello", and "World" is some non-existent boolean attribute.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download