In a PHP web page, when flling the form and some of the fields are filled incorrectly, I need to return to the same page and auto-fill all the fields that were prefiously filled by the user. How do I set the values of the fields?
I tried using the $_POST method and echo but the error was that the key I used was undefined.
3
Answers
Remember, if you do use
echo
then make sure you escape the output, ieotherwise you risk injection attacks
You can store values in an array called data$
And if there is an error, return this array to the page and use the value method to fill in the pre-filled values.
Example
And on the desired page: