"; }
if (preg_match("/[^A-z0-9_\-]/", $username)==1) { $errors++; $errorlist .= "Username must be alphanumeric.
"; } // Thanks to "Carlos Pires" from php.net!
$usernamequery = mysql_query("SELECT username FROM dk_users WHERE username='$username' LIMIT 1");
if (mysql_num_rows($usernamequery) > 0) { $errors++; $errorlist .= "Username already taken - unique username required.
"; }
// Process email address.
if ($email1 == "" || $email2 == "") { $errors++; $errorlist .= "Email fields are required.
"; }
if ($email1 != $email2) { $errors++; $errorlist .= "Emails don't match.
"; }
if (! is_email($email1)) { $errors++; $errorlist .= "Email isn't valid.
"; }
$emailquery = mysql_query("SELECT email FROM dk_users WHERE email='$email1' LIMIT 1");
if (mysql_num_rows($emailquery) > 0) { $errors++; $errorlist .= "Email already taken - unique email address required.
"; }
// Process password.
if ($password1 != $password2) { $errors++; $errorlist .= "Passwords don't match.
"; }
$password = md5($password1);
if ($errors == 0) {
$verifycode = "";
for ($i=0; $i<8; $i++) {
$verifycode .= chr(rand(65,90));
}
$query = doquery("INSERT INTO {{table}} SET id='',regdate=NOW(),verify='$verifycode',username='$username',password='$password',email='$email1',charname='$charname',charclass='$charclass',difficulty='$difficulty'", "users") or die(mysql_error());
//if (sendregmail($email1, $verifycode)) {
$page = "Your account was created successfully.
You may now continue to the Log In page and start playing ".$controlrow["gamename"]."!";
//} else {
// $page = "Your account was created successfully.
However, there was a problem sending your verification email. Please check with the game administrator to help resolve this problem.
You may now continue to the Log In page and start playing ".$controlrow["gamename"]."!";
//}
} else {
$page = "The following error(s) occurred when your account was being made:
$errorlist
Please go back and try again.";
}
} else {
$page = gettemplate("register");
$page = parsetemplate($page, $controlrow);
}
$topnav = "";
display($page, "Register", false, false, false);
}
function sendregmail($emailaddress, $vercode) {
include('config.php');
extract($appsettings);
$headers = "";
$headers .= "From: $adminname<$adminemail>\n";
$headers .= "X-Sender: <$adminemail>\n";
$headers .= "Return-Path: $adminname<$adminemail>\n";
$headers .= "X-Mailer: PHP\n";
$email = <<