Hi everybody!
Please help me with this problem. I try to write code for server side
data validation. Initially, I have a html file called "form.html" which
just contains all the necessary fields for user to submit their contact
info (name, phone, email, address.....etc...). All user's input will be
sent to "processForm.php" using POST. In processForm.php, I want to be
able to re-display the form in "form.html" with valid user's input and
error message on top of the form in case user enter invalid data.
Currently, a simple code that I could think of is the following:
<?php
if (!empty($_POST['submit']))
{
$isAllValid = false;
//Check for invalid data
//Code for checking data will be written here.
//Invalid data occur.
if(!$isAllValid)
{
include("form.html");
//set user's input in the form's fields. How to access
//form's field form here ?
}
}
else
{
echo "User not submit";
}
?>
My questions are:
1. Is there a way to access the form's fields in "form.html" to set
their values ? (given all the form's fields in form.html have unique
name)
2. If (1) is not doable, then how would I this in PHP ?
Thank you in advance !!
Jay Hana