Please provide us with this information
}
break;
case "3";
//check it all up, reset password and send email out!!
$answer = strtolower($_POST["answer"]);
$username = addslashes($_POST["hdnUsername"]);
$answer = md5($answer);
$DBQuery1 = mysql_query("SELECT answer, email FROM `users` where username = '$username'");
$DBLine = mysql_fetch_array($DBQuery1);
if (mysql_num_rows($DBQuery1) == 1){
if ($DBLine["answer"] == $answer){
//correct answer!
$email = $DBLine["email"];
$letters = range("a","z");
$letters2 = range("A","Z");
$key = "";
for($i = 0; $i < 16; $i++) {
$Rand = round(rand(1,3));
if($Rand == 1){
$key .= rand(0,9);
} elseif($Rand == 2) {
$key .= $letters[rand(0,25)];
} elseif($Rand == 3) {
$key .= $letters2[rand(0,25)];
}
}
$newpass = $key;
$newpassdisp = $newpass;
$newpass = md5($newpass);
mysql_query("UPDATE `users` set password='$newpass' where username='$username'");
mail($email, "Beyond Gaming - Password Reset","Hello $username,\nYou have requested your password to be reset.\nThis email contains your new login information.\nAfter logging in with this password please change it.\n \nNew password: $newpassdisp\n \nThank you,\nBeyond Gaming","From: accounts@beyondgaming.org");
print "Your new password has been emailed to $email";
} else {
print "Your answer did not match the answer on file. Please try again.";
}
}
break;
} // end part switch
break; // break forgot password
case "change_password";
if(empty($_SESSION)){
print "You must be logged in to change your password!";
} else {
if ($_GET["part"] == "" || !isset($_GET["part"])){
?>
}
switch($_GET["part"]) {
case "1";
?>
Please enter your Password and new passwords
break;
case "2";
$oldpass = md5($_POST["password"]);
$newpass1 = md5($_POST["newpass1"]);
$newpass2 = md5($_POST["newpass2"]);
$username = $_SESSION["user"]["name"];
if($newpass1 == $newpass2){
$DBQuery = mysql_num_rows(mysql_query("SELECT * from `users` where username='$username' and password='$oldpass'"));
if($DBQuery == 1){
//Yes
mysql_query("UPDATE `users` set password='$newpass1' WHERE username='$username'");
print "You have sucessfully changed your password
You will now be logged out.";
?>
} else {
print "Your typed password does not match your password on file";
}
} else {
print "Your passwords do not match";
}
break;
}
break; //break change password
}
} // end function switch
?>