Stop PHP form inputs returning empty after validation
This is a short and sweet snippet that will save the users form input after PHP runs validation and returns false. Very good for User Experience!
Copy this code and paste it in your HTML
<?php if(isset($_POST['FORM_INPUT_OR_TEXTAREA_NAME_GOES_HERE'])){ echo $_POST['FORM_INPUT_OR_TEXTAREA_NAME_GOES_HERE']; } ?>
SAMPLE OF A FORM INPUT:
<input name="name" size="20" value="
<?php if(isset($_POST['name'])){ echo $_POST['name']; } ?>">
SAMPLE OF A FORM TEXTAREA:
<textarea name="comments" rows=5 cols=20>
<?php if(isset($_POST['comments'])){ echo $_POST['comments']; } ?></textarea>
URL: http://www.complimedia.com/contact.php
Report this snippet
Comments
Subscribe to comments