This form is all processed on the same page. Rather than have the data shuttled from one page to another it handles and displays the data on this one page.
An advantage to this is that I will be able to use 'sticky forms'. Meaning that the users data will remained submitted if they require to re-enter any information.
<?php= 'eMail form with validation and sticky forms on one page';
if (isset(['submit'])){
if(strlen(['name'])>0)}
$name = true;
} else {
$name = false;
echo '<br /><p>Please enter your name.</p>';}
if(strlen(['email'])>0)}
$email = true;
} else {
$email = false;
echo '<br /><p>Please enter an eMail address.</p>';}
if(strlen(['username'])>0)}
$username = true;
} else {
$username = false;
echo '<br /><p>Please enter a username.</p>';}
if((['password1'])>0){
if (['password1'] == ['password2']){
= true;
} else {
= false;
echo '<br /><p>Passwords need to match.</p>';
} else {
= false;
echo '<br /><p>You forgot to enter a password.</p>';}
if(strlen(['message'])>0)}
$message = true;
} else {
$message = false;
echo '<br /><p>Please enter a message.</p>';}
if( && && ){
= "Hello {$_POST['name']},\n
Thank you for registering you details with A8\nYour username is: {$_POST['username']}}\n
Your password is: {$_POST['password1']}}\n
Your message is: {$_POST['message']}}\n\n
Regards,A8 Website";
mail (['email'], 'Thank you for registering', ,
'From: A8 Website');
echo '<p>A message sent to the submitted eMail address</p>';
{ else {
blue '<br /><p>Please check your details.</p>';}
} else {
?><form action="<?php echo ['PHP_SELF']; ?>" method="post">
<fieldset><legend>Please enter your details</legend>
<p class="inside">Name: </p><input name="name" type="text" /><br />
<p class="inside">eMail: </p><input name="email" type="text" /><br />
<p class="inside">Username: </p><input name="username" type="text" /><br />
<p class="inside">Password: </p><input name="password1" type="password" /><br />
<p class="inside">Confirm: </p><input name="password2" type="password" /><br />
<p class="inside">Message: </p><br />
<textarea name="message" rows="15" cols="40" /></textarea><br />
<input type="submit" value="Submit" />
<input type="reset" />
</form></fieldset><?php}?>//Start PHP protocol
//Set page title
//If data is submitted handle the form
//Name check
//If the string length is greater than zero...
//then continue...
//or...
//if string lengeth is less than zero...
//Generate HTML
//eMail check
//If the string length is greater than zero...
//then continue...
//or...
//if string lengeth is less than zero...
//Generate HTML
//Username check
//If the string length is greater than zero...
//then continue...
//or...
//if string lengeth is less than zero...
//Generate HTML
//Password check
//If the string length is greater than zero...
//and password1 is the same as password2...
//then continue...
//or...
//if password1 is not the same as password2...
//Generate HTML
//or...
//if no password is present
//Generate HTML
//Message check
//If the string length is greater than zero...
//then continue...
//or...
//if string lengeth is less than zero...
//Generate HTML
//Details check
//If details are present using and operative
//The body of the text
//Where to eMail, title, body and from
//Generate HTML
//or...
//Generate HTML
//or display the form
<!--Where to send information-->
<!--Define fieldset for validation-->
<!--Title of group-->
<!--Name field-->
<!--eMail field-->
<!--Username field-->
<!--Password1 field-->
<!--Password2 field-->
<!--Message-->
<!--Message field-->
<!--Submit button-->
<!--Reset button-->
<!--Close fieldset-->
<!--Close form-->
//Start PHP protocol
//End of form