Reputation: 46509
I came across the problem, I use re-captcha to validate user input. I made it so if wrong captcha was entered it displays an error message. It works fine, but once user submits form it reloads the page to show an error message, because of this all data entered by user gets lost. Is there a way to memorize what user entered before, so the only thing they need to change is a captcha text?
Here is the page: http://inelmo.com/create_story.php submit a form with wrong captcha to see an error message and you will see that all data gets lost.
Upvotes: 0
Views: 215
Reputation: 1772
As the form was submitted to the PHP script you already have access to all they information which they provided. It is simply a case of echo
ing the POST data into the markup.
Upvotes: 0
Reputation: 6251
To combat this (as well as to allow PHP-validation to work for JS disabled users) I often use:
<input type="text" id="whatever" name="whatever" value="<?= $_POST['whatever']; ?> />
This way, any submitted data will be returned. :)
Upvotes: 0
Reputation: 461
You can try settings the values for the inputs. So something like <input type="text" name="something" value="<?php echo $_POST['something'];?>">
Upvotes: 1