I got simple form to get user information then on same page I am validating form field using PHP. If user did not enter mandatory filed I want to display the same page indicating the missing files. like "mail address is required".
customer.php
Code: Select all
if(isset($_POST['getValidate']))
{
if ($_POST['fname'] == "")
{
$error[$cnt] = "Name ";
$cnt++;
echo "Name";
$erFlag = 0;
}
if($_POST['lname'] == "")
{
$error[$cnt] = "Last Name ";
$cnt++;
$erFlag = 0;
echo "Last Name";
}
if($_POST['email'] == "")
{
$error[$cnt] = "Email address ";
$cnt++;
$erFlag = 0;
echo "Email";
}
if($_POST['address1'] == "")
{
$error[$cnt] = "Address ";
$cnt++;
$erFlag = 0;
echo "Add";
}
if($_POST['address2'] == "")
{
$error[$cnt] = "Address ";
$cnt++;
$erFlag = 0;
echo "Add2";
}
if($_POST['county'] == "0")
{
$error[$cnt] = "County ";
$cnt++;
$erFlag = 0;
echo "County<br>";
echo $_POST['county']."<br>";
}
if($_POST['pcode'] == "")
{
$error[$cnt] = "Post code ";
$cnt++;
$erFlag = 0;
echo "Post Code";
}
if($_POST['tel'] == "")
{
$error[$cnt] = "telephone ";
$cnt++;
$erFlag = 0;
echo "Tele";
}
if($_POST['cel'] == "")
{
$error[$cnt] = "Mobile number ";
$cnt++;
$erFlag = 0;
echo "Mobile";
}
echo "Flag is ". $erFlag;
if($erFlag)
{
header("location:confirm.php?name=fahad");
exit;
}
else
{
}Thanks
[/quote]