So my register page isn't working for some reason and I am guessing it's not making it to the registerprocess.php part of the script for some reason because every time I hit submit I don't even get the error messages within the registerprocess.php such as invalid email, passwords don't match or user already taken... I have altered the script around as much as possible and sit at a stand still. So now I am here. I won't show some things because I know they work, like the ajax.php which checks to see if the user is capible of using ajax.
So to start with this is my register page... don't worry about the filldiv part. I am not putting every piece of detail in here so it will look funny.
register.php
<?php
$data = "<h2>Register</h2><br><form name=\'registrationForm\' method=\'post\'><table border=\'0\' cellspacing=\'0\' cellpadding=\'0\' width=\'100%\'><tr><td colspan=\'2\'><strong>Registration:</strong></td></tr><tr><td>Login name:</td><td><input type=\'text\' id=\'loginnamereg\' maxlength=\'20\' /></td></tr><tr><td>Username(In-game name):</td><td><input type=\'text\' id=\'usernamereg\' maxlength=\'20\' /></td></tr><tr><td>Email:</td><td><input type=\'text\' id=\'emailreg\' /></td></tr><tr><td>Email Again:</td><td><input type=\'text\' id=\'emailreg2\' /></td></tr><tr><td>Gender:</td><td><select id=\'genderreg\'><option value=\'Male\'>Male</option><option value=\'Female\'>Female</option></select></td></tr><tr><td>Class:</td><td><select id=\'classreg\'><option value=\'Archer\'>Archer</option><option value=\'Fighter\'>Fighter</option><option value=\'Knight\'>Knight</option><option value=\'Sorcerer\'>Sorcerer</option></select></td></tr><tr><td>Password:</td><td><input type=\'password\' id=\'passwordreg\' /></td></tr><tr><td>Password Again:</td><td><input type=\'password\' id=\'passwordvreg\' /></td></tr><tr><td>Security Question:</td><td><input type=\'text\' id=\'secquestion\' /></td></tr><tr><td>Answer:</td><td><input type=\'text\' id=\'secanswer\' /></td></tr><tr><td colspan=\'2\'><input type=\'button\' id=\'register\' value=\'Register\' onclick=\'goRegister();\' /><input type=\'button\' id=\'reset\' value=\'Reset\' onclick=\'cleanReg();\' /><input type=\'button\' id=\'cancel\' value=\'Cancel\' onclick=\'viewHome();\' /></td></tr></table></form>";
print("fillDiv('body','".$data."');");
?>
The leading up to the registerprocess.php
homefunctions.js
function goRegister(){
userLoginname = $("loginnamereg").value;
userAlias = $("usernamereg").value;
userPass = $("passwordreg").value;
userVPass = $("passwordvreg").value;
userEmail = $("emailreg").value;
userVEmail = $("emailreg2").value;
userGender = $("genderreg").value;
userClass = $("classreg").value;
userSecurityquestion = $("secquestion").value;
userSecurityanswer = $("secanswer").value;
data = "userLoginname=" + userLoginname + "&userAlias=" + userAlias + "&userPass=" + userPass + "&userVPass=" + userVPass + "&userEmail=" + userEmail + "&userVEmail=" + userVEmail + "&userGender=" + userGender + "&userClass=" + userClass + "&userSecurityquestion=" + userSecurityquestion + "&userSecurityanswer=" + userSecurityanswer;
evalpostAJAXHtml("registerprocess.php",data,0);
}
function cleanReg(){
document.registrationForm.loginnamereg.value = "";
document.registrationForm.usernamereg.value = "";
document.registrationForm.emailreg.value = "";
document.registrationForm.emailreg2.value = "";
document.registrationForm.passwordreg.value = "";
document.registrationForm.passwordvreg.value = "";
document.registrationForm.genderreg.value = "Male";
document.registrationForm.classreg.value = "Archer";
document.registrationForm.secquestion.value = "";
document.registrationForm.secanswer.value = "";
}
And finally the register process form...
registerprocess.php
<?php
include('connect.php');
$loginname = $_POST['userLoginname'];
$username = ucwords(strtolower($_POST['userAlias']));
$password = md5($_POST['userPass']);
$email = $_POST['userEmail'];
$gender = $_POST['userGender'];
$class = $_POST['userClass'];
$securityquestion = $_POST['userSecurityquestion'];
$securityanswer = $_POST['userSecurityanswer'];
$getuser = mysql_query("SELECT * FROM characters WHERE username='".$username."'");
if($_POST['userLoginname'] != "" && $_POST['userAlias'] != "" && $_POST['userPass'] != "" && $_POST['userVPass'] != "" && $_POST['userEmail'] != "" && $_POST['userVEmail'] != "" && $_POST['userSecurityquestion'] != "" && $_POST['userSecurityanswer'] != "")
{
if($securityquestion == $securityanswer){
print("fillDiv('displayArea','Your security question and security answer seem to be matching. Choose something more difficult.');");
exit;
}
$getlogin = mysql_query("SELECT * FROM characters WHERE loginname='".$loginname."'");
if(mysql_num_rows($getlogin) == 1)
{
print("fillDiv('displayArea','Somone already appears to have that login name. Please choose another.');");
exit;
}
if($email != $_POST['userVEmail']){
print("fillDiv('displayArea','Your emails don\'t appear to be matching.');");
exit;
}
if(eregi("^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$", $email))
{
if(mysql_num_rows($getuser) == 1)
{
print("fillDiv('displayArea','Sorry, the username \'".$username."\' has already been taken. Please choose another!');");
}
else
{
$charset = "abcdefghijklmnopqrstuvwxyz1234567890";
$i = "1";
while($i < "15")
{
$key .= $charset[(mt_rand(0,(strlen($charset)-1)))];
$i ++;
}
$to = $email;
$subject = "Rise of Immortals Activation Key";
$messager = "Hello ".$username."!\n Thank you for registering at http://riseofimmortals.com. Visit the following address to activate your account: http://riseofimmortals.com/activate.php?key=".$key."\n Please remember you will login with your login name and NOT your username. Your login name is : ".$loginname.".Hope to see you there soon, Rise of Immortals Support Team.";
$headers = "From: donotreply@riseofimmortals.com";
mail($to,$subject,$messager,$headers);
if($class == "Archer")
{
$str = "30";
$dex = "40";
$end = "40";
$int = "20";
$con = "30";
}
elseif($class == "Fighter")
{
$str = "50";
$dex = "20";
$end = "50";
$int = "20";
$con = "20";
}
elseif($class == "Knight")
{
$str = "60";
$dex = "10";
$end = "50";
$int = "10";
$con = "30";
}
elseif($class == "Sorcerer")
{
$str = "20";
$dex = "20";
$end = "20";
$int = "50";
$con = "50";
}
$createuser = mysql_query("INSERT INTO characters (`loginname`, `username`, `password`, `email`, `securityquestion`, `securityanswer`, `gender`, `class`, `strength`, `dexterity`, `endurance`, `intelligence`, `concentration`, `ip`) VALUES ('".$loginname."', '".$username."', '".$password."', '".$email."', '".$securityquestion."', '".$securityanswer."', '".$gender."', '".$class."', '".$str."', '".$dex."', '".$end."', '".$int."', '".$con."', '".$_SERVER['REMOTE_ADDR']."')") or die(mysql_error());
$createkey = mysql_query("INSERT INTO activation (`username`, `key`) VALUES ('".$username."', '".$key."')") or die(mysql_error());
print("fillDiv('displayArea','Thank you ".$username.", your registration was successful.<br />Please note that your IP address has been recorded for security purposes.<br /><br /><font color=\'#00DD00\'>Check your email address for your activation key, you cannot play on this character before it is activated.</font>');");
print("cleanReg();");
}
}
else
{
print("fillDiv('displayArea','You do not appear to have entered a valid email address.<br /><font color=\'#DD0000\'>A valid email address is required for registration, you cannot play the game without it!</font>');");
}
}
else
{
print("fillDiv('displayArea','You need to complete all boxes to be able to register.');");
}
?>
And just the throw out there here is how the filldiv piece works.
dom.js
function $(id){
return document.getElementById(id);
}
function fillDiv(id,data){
$(id).innerHTML = data;
}
Okay, so I just don't know how to get it working because it wont process the posted data for some reason =(
This is the last place I come to. If you could help that would be greatly appreciated. Thanks, Beffic.