<?php
// Create an empty array to hold the error messages.
$arrErrors = array();
//Only validate if the Submit button was clicked.
if (!empty($POST['Submit'])) {
// Each time there's an error, add an error message to the error array
// using the field name as the key.
if ($POST['name']=='')
$arrErrors['name'] = 'Please provide a your name.';
if ($POST['biz']=='')
$arrErrors['biz'] = 'Please provide your business name.';
if ($POST['abn']=='')
$arrErrors['abn'] = 'Please provide your ABN number.';
if ($POST['street']=='')
$arrErrors['street'] = 'Please provide a street name.';
if ($POST['suburb']=='')
$arrErrors['suburb'] = 'Please provide a suburb.';
if ($POST['state']=='')
$arrErrors['state'] = 'Please provide a state.';
if ($POST['country']=='')
$arrErrors['country'] = 'Please provide a country.';
if ($POST['pcode']=='')
$arrErrors['pcode'] = 'Please provide a post code.';
if ($POST['phone']=='')
$arrErrors['phone'] = 'Please provide a telephone number.';
if ($POST['email']=='')
$arrErrors['email'] = 'Please provide a valid email address.';
if ($POST['user']=='')
$arrErrors['user'] = 'Please provide a username.';
if ($POST['pass']=='')
$arrErrors['pass'] = 'Please provide a password.';
if ($POST['security'] != $SESSION['security'])
$arrErrors['security'] = 'Please provide a valid security code.';
if (count($arrErrors) == 0) {
// If the error array is empty, there were no errors.
// Insert form processing here.
$sql = "INSERT INTO users (type, name, biz, abn, street, suburb, state, country, pcode, phone, fax, mobile, email, user, pass, logo, status, stockist, added)
VALUES ('" . $POST['type'] . "', '" . $POST['name'] . "', '" . $POST['biz'] . "', '" . $POST['abn'] . "', '" . $POST['street'] . "', '" . $POST['suburb'] . "', '" . $POST['state'] . "', '" . $POST['country'] . "', '" . $POST['pcode'] . "', '" . $POST['phone'] . "', '" . $POST['fax'] . "', '" . $POST['mobile'] . "', '" . $POST['email'] . "', '" . $POST['user'] . "', '" . $POST['pass'] . "', '" . $POST['logo'] . "', '" . $POST['status'] . "', '" . $POST['stockist'] . "', '" . $POST['added'] . "')";
$result = mysql_query($sql);
$to="xxx@xxx.xxx";
$subject="New Wholesale Account Application";
$name="Account Enquiry for Kiik Fashion";
$message="Hi<br><br> ".$_REQUEST['name']." has requested a wholesale account on behalf of ".$_REQUEST['biz'].". Please log in and review their request.<br><br>Thank you.";
mail("$to","$subject","$message","From: $name <$email>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");
header('Location: thanks.php');
} else {
// The error array had something in it. There was an error.
// Start adding error text to an error string.
$strError = '<div class="formerror"><p><img src="/images/triangle_error.gif" width="16" height="16" hspace="5" alt="">Please check the following and try again:</p><ul>';
// Get each error and add it to the error string
// as a list item.
foreach ($arrErrors as $error) {
$strError .= "<li class='indent'>$error</li>";
}
$strError .= '</ul></div>';
}
}
?>
<link href="site_layout.css" rel="stylesheet" type="text/css" />
<form method="post" action="register.php">
<table cellpadding="0" cellspacing="0" border="0" width="800" class="register">
<tr><td height="22" colspan="5" align="left"> <b>Wholesale Application Form</b></td></tr>
<tr><td colspan="5" align="left"> <font face="Geneva, Arial, Helvetica, sans-serif" color="#FF0000"><b>R</b></font> - Indicated Required Fields</font></span></td>
</tr>............