include_once("radmin/include_config.php");
define("TABLE_MAIN","registered_users");
// Are we saving the record?
if (!empty($_POST["submit_form"])) {
// Check we have everything we need
$_POST["addNewItem"]=1;
if (empty($_POST["user_name"])) { ERR("Please ensure you have entered a username"); }
if (empty($_POST["user_email"])) { ERR("Please ensure you have entered an email address"); }
if (empty($_POST["user_password"])) { ERR("Please ensure you entered a password"); }
else {
// Encrypt the password
$_POST["encrypted_password"]=$encryptor->encrypt($_POST["user_password"]);
}
// Check the email address is unique
$SQL = "SELECT * FROM `".TABLE_MAIN."` WHERE (`user_email`=".$conn->qstr($_POST["user_email"]).") LIMIT 1";
$recordSet = &$conn->Execute($SQL);
if ($conn->ErrorNo() > 0) ERR("An error occured searching the database!
Error Msg: ".$conn->ErrorMsg());
elseif (!$recordSet->EOF && isset($recordSet->fields[0])) ERR('The email address "'.$_POST["user_email"].'" has already been registered.');
// Add the new database record
if (empty($GLOBALS["error"])) {
$SQL ="INSERT INTO `".TABLE_MAIN."` (";
$SQL.="`user_name`, ";
$SQL.="`user_title`, ";
$SQL.="`user_company`, ";
$SQL.="`user_address1`, ";
$SQL.="`user_address2`, ";
$SQL.="`user_address3`, ";
$SQL.="`user_address4`, ";
$SQL.="`user_address5`, ";
$SQL.="`user_telephone`, ";
//$SQL.="`user_cat1`, ";
//$SQL.="`user_cat2`, ";
//$SQL.="`user_cat3`, ";
//$SQL.="`user_cat4`, ";
//$SQL.="`user_cat5`, ";
//$SQL.="`user_cat6`, ";
$SQL.="`receive_updates`, ";
$SQL.="`user_email`, ";
$SQL.="`user_password`, ";
$SQL.="`status`, ";
$SQL.="`last_updated`, ";
$SQL.="`user_created`";
$SQL.=") ";
$SQL.="VALUES (";
$SQL.=$conn->qstr($_POST["user_name"]).", ";
$SQL.=$conn->qstr($_POST["user_title"]).", ";
$SQL.=$conn->qstr($_POST["user_company"]).", ";
$SQL.=$conn->qstr($_POST["user_address1"]).", ";
$SQL.=$conn->qstr($_POST["user_address2"]).", ";
$SQL.=$conn->qstr($_POST["user_address3"]).", ";
$SQL.=$conn->qstr($_POST["user_address4"]).", ";
$SQL.=$conn->qstr($_POST["user_address5"]).", ";
$SQL.=$conn->qstr($_POST["user_telephone"]).", ";
//$SQL.=$conn->qstr(alt($_POST["user_cat1"],NO)).", ";
//$SQL.=$conn->qstr(alt($_POST["user_cat2"],NO)).", ";
//$SQL.=$conn->qstr(alt($_POST["user_cat3"],NO)).", ";
//$SQL.=$conn->qstr(alt($_POST["user_cat4"],NO)).", ";
//$SQL.=$conn->qstr(alt($_POST["user_cat5"],NO)).", ";
//$SQL.=$conn->qstr(alt($_POST["user_cat6"],NO)).", ";
$SQL.=$conn->qstr(alt($_POST["receive_updates"],NO)).", ";
$SQL.=$conn->qstr($_POST["user_email"]).", ";
$SQL.=$conn->qstr($_POST["encrypted_password"]).", ";
$SQL.=$conn->qstr(STATUS_LIVE).", ";
$SQL.="NOW(), ";
$SQL.="NOW()";
$SQL.=")";
if ($conn->Execute($SQL) === false) { ERR("An error occured ".(empty($_POST["user_id"])?'inserting':'updating')." the details to the database.
Error Msg: ".$conn->ErrorMsg()); }
else {
// Any new file(s) to upload?
if ($conn->Insert_ID()>0) { $_POST["user_id"]=$conn->Insert_ID(); }
ERR("You have successfully registered
Thank you");
// Send a couple of emails
$emailTo="paul@pjweb.co.uk";
$emailMsg="Thank you for registering with Pulse Fitness\r\n\r\n";
$emailMsg.="To login please go to http://www.pulsefitness.com/sitelogin.htm and use the details:\r\n";
$emailMsg.="Email: ".$_POST["user_email"]."\r\n";
$emailMsg.="Password: ".$_POST["user_password"]."\r\n";
if (!empty($_POST["user_email"]))
mail("email@pulsefitness.com", "Pulse Fitness Registration", $emailMsg, "From: email@pulsefitness.com", "-femail@pulsefitness.com");
if (!empty($emailTo))
mail($emailTo, "Pulse Fitness Registration", $emailMsg, "From: email@pulsefitness.com", "-femail@pulsefitness.com");
// Now log them in
$_SESSION["session_reg_user_id"] = $_POST["user_id"];
$_SESSION["session_reg_user_name"] = $_POST["user_name"];
$_SESSION["session_reg_user_email"] = $_POST["user_email"];
$_SESSION["session_reg_user_password"] = $_POST["user_password"];
// Update the "last logged in" field in the database
$SQL="UPDATE `".TABLE_MAIN."` SET `user_lastlogin`=NOW() WHERE `user_id`=".$conn->qstr($_SESSION["session_reg_user_id"]);
if ($conn->Execute($SQL) === false) { /* Ignore errors */ }
}
}
}
?>
Pulse Fitness Registration
 |
include("include_search.php"); ?>
|