Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

2 posts by 2 authors in: Forums > CMS Builder
Last Post: August 14, 2017

I have created a form that submits user-entered data to the database and sends the data in an email. The form also has error handling. 

I have an issue when a user submits a form with errors: the fields that were filled out correctly reset to empty. This becomes annoying because the user has to re-enter all of their information.

This problem only happens with text areas, checkboxes and pulldowns. Text boxes retain the information.

So this code retains info:

<div class="form-group">
<label class="control-label" for="petname">Pet Name</label>  
<div>
<input id="textinput" name="petname" type="text" placeholder="Pet Name" class="form-control input-md" value="<?php echo htmlspecialchars(@$_REQUEST['petname']) ?>">
</div>
</div>

But this code doesn't:

<div class="form-group">
<label class="control-label" for="title"><h3>Your Vet's Details</h3></label>  
<div class="form-group">
<label class="control-label" for="address">Vet's Name and Address</label>  
<div>
<textarea class="form-control" rows="3" name="vetaddress" value="<?php echo htmlspecialchars(@$_REQUEST['vetaddress']) ?>"></textarea>
</div>
</div>
</div>

Any advice as to where I am going wrong would be gratefully received.

I have also attached the php file.

Thanks

Attachments:

layout-form-custom.php 15K

Hi Jeff, 

This should work for the textarea: 

<textarea class="form-control" rows="3" name="vetaddress">
<?php echo htmlspecialchars(@$_REQUEST['vetaddress']) ?>
</textarea>

For the other fields, try getting them to display default selections or data in a plain html page.  Once you can do it with plain HTML then you can automate it with PHP.  

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com