Your php output is practically unreadable. It appears to be moving variables from a REQUEST into local storage, then building an email using those local variables, then sending the email using the mail() command.
This is stock stuff.
I guess I'm confused; you want to validate and enforce certain fields? And kick it back to them if those fields are not filled in properly?
Like this, generally:
Code:
The name of this script, for our purposes, is myscript.php
<?php
allow_send = 0;
formerror = 0;
if($_REQUEST_METHOD == "POST")
{
$receiver = 'me@email'; $subject = 'New registration'; #$message = 'This is a new registration.'; $surname = $_POST['surname']; $firstname = $_POST['firstname']; $address = $_POST['address']; $email = $_POST['email']; $homeph = $_POST['homeph']; $mobileph = $_POST['mobileph']; $workph = $_POST['workph']; $time = $_POST['time']; #from here $oldaddress = $_POST['oldaddress']; $DOB = $_POST['DOB']; $elect = $_POST['elect']; $job = $_POST['job']; $salary = $_POST['salary']; $employer = $_POST['employer']; $benefit = $_POST['benefit']; $smoke = $_POST['smoke']; $claim = $_POST['claim']; $children = $_POST['children']; $children2 = $_POST['children2']; $pets = $_POST['pets']; $pets2 = $_POST['pets2']; $require = $_POST['require']; $terms = $_POST['terms']; $rooms = $_POST['rooms'];
validate anything you want to validate, and implement security to prevent your form being used as a spam relay
if(all_validations_are_passed)
{
formerror = 0;
allow_send = 1;
mail(etc);
}
else formerror = 1;
}
?>
<html><head></head><body>
<?php
if(allow_send == 1)
{
echo "the message was sent<br/>";
} else {
?>
<form action = "myscript.php" method="POST">
<?php
if(formerror == 1) {
echo "there are errors in the form. Please correct them.<br/>
}
?>
html blah blah, with values put in textboxes etc
<?php } ?>
In such a form, when marking up errors, I'll usually change the fonts on the lines that have the problems into red so that the user can easily see what I want fixed..