I have a piece of php code which validates my form which works but would now like it to insert the data to database if there are no errors.
Is it possible to do so in the one php file??
Here is my php validation.
Thanks
Is it possible to do so in the one php file??
Here is my php validation.
Code:
if ($_POST['submitted']==1) {
$errormsg = ""; //Initialize errors
if ($_POST[TestTime]){
$TestTime = $_POST[TestTime]; //If title was entered
}
else{
$errormsg = "Please enter TestTime";
}
if ($_POST[PassFail]){
$PassFail = $_POST[PassFail]; //If comment was entered
}
else{
if ($errormsg){ //If there is already an error, add next error
$errormsg = $errormsg . " & content";
}else{
$errormsg = "Please enter content";
}
if ($errormsg){ //If any errors display them
echo "<script type='text/javascript'>alert('$errormsg')</script>";
}
}
}
Thanks