'.
'Please fill them in and try again.');
}
// Check for existing user with the new id
$sql = "SELECT COUNT(*) FROM user WHERE username = '$_POST[username]'";
$result = mysql_query($sql);
if (!$result) {
error('A database error occurred in processing your '.
'submission.
If this error persists, please '.
'contact you@example.com.');
}
if (mysql_result($result,0,0)>0) {
error('A user already exists with your chosen userid.
'.
'Please try another.');
}
$newsletter = ($_POST[newsletter] == "on" ? 1 : 0);
$newpass = generatePassword();
$newpassMd = md5($newpass);
$sql = "INSERT INTO user SET
username = '$_POST[username]',
password = PASSWORD('$newpassMd'),
firstname = '$_POST[firstname]',
lastname = '$_POST[lastname]',
email = '$_POST[email]',
newsletter = '$newsletter'";
if (!mysql_query($sql))
error('A database error occurred in processing your '.
'submission.
If this error persists, please '.
'contact you@example.com.
' . mysql_error());
// Email the new password to the person.
$message = "G'Day!
Your personal account for the Project Web Site
has been created! To log in, proceed to the
following address:
http://www.example.com/
Your personal login ID and password are as
follows:
username: $_POST[username]
password: $newpass
You aren't stuck with this password! Your can
change it at any time after you have logged in.
If you have any problems, feel free to contact me at
.
-Your Name
Your Site Webmaster
";
echo $message;
?>
Registration Complete
User registration successful!
Your userid and password have been emailed to
, the email address
you just provided in your registration form. To log in,
click here to return to the login
page, and enter your new personal userid and password.