you need to put each check in its own if statement. once and else if loop finds a match it stops executing the rest of the statements. Also, you need to write the errors to an array in case you have multiple errors on a form.
<?php include('database name here');
session_start();
$validation_id = strval(time());
if (isset($_POST['submit'])) {
// Create empty array to hold errors
$errors = array();
if ($_POST['first_name'] == "") {
// append new entry into the array
$errors[] = "Please enter a first name";
}
if ($_POST['last_name'] == "") {
$errors[] = "Please enter a surname";
}
if ($_POST['DOB'] == "") {
$errors[] = "Please enter your birthday in the format dd/mm/yyy";
}
if ($_POST['email'] == "") {
$errors[] = "Please enter the user's email";
}
if ($_POST['username'] == "") {
$errors[] = "Please enter a username";
}
if ($_POST['password'] == "") {
$errors[] = "Please enter a password";
}
// check if we added any errors to the array
if ( count($errors) > 0 ) {
// we have errors so we need to echo them back to the user
// start a list to hold them
echo '<ul>';
// echo out each error in the array
foreach ($errors as $error) {
echo '<li class="error">'.$error.'</li>';
}
// close our ul
echo '</ul>';
} else {
// No errors... process the data
$first_name = mysql_real_escape_string($_POST['first_name']);
$last_name = mysql_real_escape_string($_POST['last_name']);
$DOB = mysql_real_escape_string($_POST['DOB']);
$sex = mysql_real_escape_string($_POST['sex']);
$email = mysql_real_escape_string($_POST['email']);
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$agree = mysql_real_escape_string($_POST['agreed']);
$creation_date = mysql_real_escape_string($_POST['creation_date']);
$user_type = mysql_real_escape_string($_POST['member_type']);
$access_level = mysql_real_escape_string($_POST['access_level']);
$validation = mysql_real_escape_string($_POST['validation_id']);
$club_user = mysql_real_escape_string($_POST['user_type']);
$insert_member= "INSERT INTO Members (`first_name`,`last_name`,`DOB`,`sex`,`email`,`username`,`password`,`agree`,`creation_date`,`usertype`,`access_level`,`validationID`)
VALUES
('".$first_name."','".$last_name."','".$DOB."','".$sex."','".$email."','".$username."','".$password."','".$agree."','".$creation_date."','".$user_type."','".$access_level."', '".$validation."')";
$insert_member_now= mysql_query($insert_member) or die(mysql_error());
}
}
Also you can add multiple arguments to an if statement by using either || or && (or, and)
If ( ($a == $b) || ($b ==$c) ) { then do this }
If ( ($a == $b) && ($b ==$c) ) { then do this }
Hope this all made sense... good luck!