<?php
include_once("config.php");
//Haven't seen the form so display it!
if ($_POST[opp] != "register.php")
{
include_once("register_form.php");
}
//Have already seen the form
else
{
//Inlclude the form validator script
include ("FormValidator.class.inc");
$checkform = new FormValidator();
//Get the contents of the form variables
$f_name = $_POST[f_name];
$s_name = $_POST[s_name];
$email = $_POST;
$b_date = $_POST[day].$_POST[month].$_POST[year];
$password1 = $_POST[password1];
$password2 = $_POST[password2];
//Check to see if email address is already registered
//open a connection to the database
$conn = mysql_connect("localhost",$username, $password) or die(mysql_error());
//Select database
mysql_select_db("$database",$conn) or die(mysql_error());
//Create the query
$sql = "select * from members
where
email = '$_POST[email]';";
//Issue query
$result = mysql_query($sql,$conn) or die(mysql_error());
//Check the number of return rows
if (mysql_num_rows($result) > 0)
{
$checkform->AddErrorMsg("Email","Email address already registered");
}
//Close connection
mysql_close($conn);
//Validate the form data
$checkform->isEmpty("f_name","Please enter a forename");
$checkform->isEmpty("s_name","Please enter a surname");
$checkform->isEmailAddress("email","Please enter a valid email address");
$checkform->isValidDate("b_date","Please enter a valid date",$_POST[day],$_POST[month],$_POST[year]);
$checkform->isOver16("b_date","You must 16 years old to use this service!!",$_POST[day],$_POST[month],$_POST[year]);
$checkform->isValidPassword("password1","password2","The passwords you entered do not match","Your password must be a minimum of 5 characters!!");
//Check the terms & Conditions have been read
if ($_POST[terms] != "yes")
{
$checkform->AddErrorMsg("terms","Please verify you have read our Terms & Conditions");
}
//Check to see if any errors have occured
if ($checkform->isError())
{
$errorlist = $checkform->getErrorList();
foreach ($errorlist as $error)
{
echo "*".$error['msg']."<br>";
}
include_once("register_form.php");
}
//Add to database
else
{
//open a connection to the database
$conn = mysql_connect("localhost",$username,$password) or die(mysql_error());
//Select database
:eek4:[B]mysql_select_db("$database",$conn) or die(mysql_error());[/B]
//Prepare the insert statement
$b_date = $_POST[year]."-".$_POST[month]."-".$_POST[day];
$add_member = "insert into members values('','$_POST[f_name]','$_POST[s_name]','$b_date','$_POST[email]',password('$_POST[password1]'),'10',CURRENT_DATE(),'$_POST[edtype]','0','$_POST[inform]','$_POST[us]')";
//Insert the job into the table
mysql_query($add_member, $conn) or die(mysql_error());
//Get variables for activation
$sql = "SELECT * FROM members WHERE id = LAST_INSERT_ID()";
$result = mysql_query($sql, $conn) or die(mysql_error());
$password = mysql_result($result, 0, 'password');
//Close connection
mysql_close($conn);
include_once("messages/message_activation.php");
echo "Your membership information has been mailed to your email address. Please check it and follow the directions<BR><p>";
echo "You <B>MUST</B> click on the link provided in the email you have been sent to activate your account <BR></p><p>";
echo "<B>Note:</B> If you have not received an email from us please contact us or try looking in another <B>folder</B> in your email account.<BR></p>";
}
};
?>