Hi guys what is the proper coding of this if else statement if name midname last name email phone for required field and a validation.
if (!preg_match("/^[a-zA-Z ]*$/",$name))
{
die("First Name Should be letters and white space only!");
}
if (!preg_match("/^[a-zA-Z ]*$/",$miname))
{
die("Please Enter Your Middle Name!");
}
if (!preg_match("/^[a-zA-Z ]*$/",$lastname))
{
die("Please Enter Your Last Name!");
}
if (!preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z] {2,3})$/i",$email))
{
die("E-mail address not valid");
}
else if (!preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i",$phone))
{
die("Phone should only contain 11 digits and start with (09)!");
}
if($_POST["inputName"] &&$_POST["inputmiName"]&&$_POST["inputlName"] && $_POST["inputEmail"]&& $_POST["inputPhone"]&& $_POST["inputEvent"]&& $_POST["date"]){ $name= $_POST["inputName"]; $miname= $_POST["inputmiName"]; $lastname= $_POST["inputlName"]; $email= $_POST["inputEmail"]; $phone= $_POST["inputPhone"]; $date= $_POST["date"];}
else{ exit("Please Complete The Form!");}
$sql = "INSERT INTO `catering` (`name`, `miname`,`lastname`,`email`, `phone`, `event`, `food`, `foodA`, `foodB`, `foodC`, `foodD`, `foodE`, `foodF`, `foodG`, `foodH`, `foodI`, `foodJ`, `pack1`,`total`,`date`, `date_join`) VALUES ( ' ". $name ." ' ,' ". $miname ." ' ,' ". $lastname ." ' ,' ". $email ." ' ,' ". $phone ." ' ,' ". $event ." ' ,' ". $foodvariable ." ' , ' ". $foodvariableA ." ', ' ". $foodvariableB ." ' , ' ". $foodvariableC ." ' , ' ". $foodvariableD ." ' , ' ". $foodvariableE ." ' , ' ". $foodvariableF ." ' , ' ". $foodvariableG ." ' , ' ". $foodvariableH ." ' , ' ". $foodvariableI ." ' , ' ". $foodvariableJ ." ' ,' ". $pack1 ." ' ,' ". $total ." ', ' ". $date_new ." ' ,NOW());";
if( mysqli_query($conn, $sql )) echo "Food Reservation SENT![Your Reservation Is only Valid for 3 days. after 3days we will call you to confirm if you will continue your reservation Thank You!";
?>
diebecause the script will end if any of the validation conditions become true