//Retrieve form inputs.
$strMemberID = generateMemberID();
$strMemberName = isset($_POST['txtMemberName']) ? trim($_POST['txtMemberName']) : "";
$strMemberPassword1 = isset($_POST['txtMemberPassword1']) ? trim($_POST['txtMemberPassword1']) : "";
$strMemberPassword2 = isset($_POST['txtMemberPassword2']) ? trim($_POST['txtMemberPassword2']) : "";
$strMemberType = isset($_POST['lstMemberType']) ? trim($_POST['lstMemberType']) : "Regular";
$strMemberEmail = isset($_POST['txtMemberEmail']) ? trim($_POST['txtMemberEmail']) : "";
$strMemberFullName = isset($_POST['txtMemberFullName']) ? trim($_POST['txtMemberFullName']) : "";
$strMemberAddress = isset($_POST['txtMemberAddress']) ? trim($_POST['txtMemberAddress']) : "";
$strMemberContactNumber = isset($_POST['txtMemberContactNumber']) ? trim($_POST['txtMemberContactNumber']) : "";
//Reset status message.
$strErrorMessage = "";
$strSuccessMessage = "";
//If submit button is clicked,
if(isset($_POST['btnSubmit']))
{
//If no member name is entered,
if(trim($strMemberName) == "")
{
$strErrorMessage = "Please enter user name.";
}
//If no member password is entered,
else if(trim($strMemberPassword1) == "")
{
$strErrorMessage = "Please enter password.";
}
//If no password confirmation is entered,
else if(trim($strMemberPassword2) == "")
{
$strErrorMessage = "Please confirm password.";
}
//If passwords do not match,
else if(trim($strMemberPassword1) != trim($strMemberPassword2))
{
$strErrorMessage = "Passwords do not match.";
}
//If no member type is selected,
else if(trim($strMemberType) == "")
{
$strErrorMessage = "Please select account type.";
}
//If no member email is entered,
else if(trim($strMemberEmail) == "")
{
$strErrorMessage = "Please enter email address.";
}
//If email address is invalid,
[COLOR="Red"]else if(! preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $strMemberEmail))[/COLOR]
{
$strErrorMessage = "Please enter valid email address.";
}
//If no full name is entered,
else if(trim($strMemberFullName) == "")
{
$strErrorMessage = "Please enter full name.";
}
//If no address is entered,
else if(trim($strMemberAddress) == "")
{
$strErrorMessage = "Please enter address.";
}
//If no contact number is entered,
else if(trim($strMemberContactNumber) == "")
{
$strErrorMessage = "Please enter contact number.";
}
//Otherwise,
else
{
//Get member information.
$sqlQuery = "SELECT * FROM member_tbl WHERE member_name = '" . $strMemberName . "' OR member_email = '" . $strMemberEmail . "'";
//Execute query.
$cmdQuery = mysql_query($sqlQuery) or die(mysql_error());
//If at least one record is found,
if(mysql_num_rows($cmdQuery) > 0)
{
$strErrorMessage = "User name / email address is already registered.";
}
//Otherwise,
else