if($charname==""){$errors++;$errorlist.="Character Name field is required.<br />";}
if(preg_match("/[^A-z0-9_\-]/",$charname)==1){$errors++;$errorlist.="Character Name must be alphanumeric.<br />";}// Thanks to "Carlos Pires" from php.net!
$characternamequery=doquery("SELECT charname FROM {{table}} WHERE charname='$charname' LIMIT 1","users");
if(mysql_num_rows($characternamequery)>0){$errors++;$errorlist.="Character Name already taken - unique Character Name required.<br />";}
$query=doquery("INSERT INTO {{table}} SET id='',regdate=NOW(),verify='$verifycode',username='$username',password='$password',email='$email1',charname='$charname',charclass='$charclass',difficulty='$difficulty'","users")ordie(mysql_error());
$page="Your account was created successfully.<br /><br />You should receive an Account Verification email shortly. You will need the verification code contained in that email before you are allowed to log in. Once you have received the email, please visit the <a href=\"users.php?do=verify\">Verification Page</a> to enter your code and start playing.";
}else{
$page="Your account was created successfully.<br /><br />However, there was a problem sending your verification email. Please check with the game administrator to help resolve this problem.";
}
}else{
$page="Your account was created succesfully.<br /><br />You may now continue to the <a href=\"login.php?do=login\">Login Page</a> and continue playing ".$controlrow["gamename"]."!";
$page="The following error(s) occurred when your account was being made:<br /><span style=\"color:red;\">$errorlist</span><br />Please go back and try again.";
$controlrow["verifytext"]="<br /><span class=\"small\">A verification code will be sent to the address above, and you will not be able to log in without first entering the code. Please be sure to enter your correct email address.</span>";
// If we've made it this far, should be safe to update their account.
$updatequery=doquery("UPDATE {{table}} SET verify='1' WHERE username='$username' LIMIT 1","users");
display("Your account was verified successfully.<br /><br />You may now continue to the <a href=\"login.php?do=login\">Login Page</a> and start playing the game.<br /><br />Thanks for playing!","Verify Email",false,false,false);
$userquery=doquery("SELECT email FROM {{table}} WHERE email='$email' LIMIT 1","users");
if(mysql_num_rows($userquery)!=1){die("No account with that email address.");}
$newpass="";
for($i=0;$i<8;$i++){
$newpass.=chr(rand(65,90));
}
$md5newpass=md5($newpass);
$updatequery=doquery("UPDATE {{table}} SET password='$md5newpass' WHERE email='$email' LIMIT 1","users");
if(sendpassemail($email,$newpass)==true){
display("Your new password was emailed to the address you provided.<br /><br />Once you receive it, you may <a href=\"login.php?do=login\">Log In</a> and continue playing.<br /><br />Thank you.","Lost Password",false,false,false);
}else{
display("There was an error sending your new password.<br /><br />Please check with the game administrator for more information.<br /><br />We apologize for the inconvience.","Lost Password",false,false,false);
display("Your password was changed successfully.<br /><br />You have been logged out of the game to avoid cookie errors.<br /><br />Please <a href=\"login.php?do=login\">log back in</a> to continue playing.","Change Password",false,false,false);