Trouble storing initial values on a form submitted with an error

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

By JeffC - August 11, 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

Jeff
Attachments:

layout-form-custom.php 15K