View Single Post
Old 01-27-2013, 01:52 AM   PM User | #1
njfail
Regular Coder

 
Join Date: Aug 2010
Posts: 125
Thanks: 2
Thanked 0 Times in 0 Posts
njfail is an unknown quantity at this point
validating a form, can it have 2 values?

Hey guys, I'm just learning PHP, and I'm trying to validate a form.
The problem I'm having, is with value=

Here is a snipit of the form code as an example:
Code:
<label>Full Name
<span class="small">First Name Last Name</span>
</label>
<input onfocus="this.value=''" type="text" value="John Smith" name="name" id="name" />
I have the value set as an example of the field, and it disappears when the user clicks the field.
But the validation tutorial I'm following is telling me to set the value as
Code:
value="<?=$varname;?>
I believe that this prevents the individual from having to re-enter their information if they forgot a field, thus triggering the validation/error message and reloading the page.

How can I have the 'example' of the field and the var so that people don't have to re-enter their information when the form is validated?

Please give me an example of the correct code, as I'm still learning

Thanks!

Last edited by njfail; 01-27-2013 at 02:08 AM..
njfail is offline   Reply With Quote