include 'db.html';
display_top("Change/Request Your Password", "", "");
if($_POST['test']==1){
if($_POST['pass2']!=$_POST['pass3']){
echo 'Your new passwords did not match';
}else{
$password2 = formating($_POST['pass1']);
$npass = formating($_POST['pass2']);
if($npass!=$_POST['pass2']){
echo 'Only use normal characters
';
}else{
if((strlen($npass)<=5)||(strlen($npass)>=13)){
echo 'Your new password must be at least 6 characters long and no more than 12 characters long
';
}else{
$sql = mysql_query("SELECT id FROM students WHERE pass='$password2'");
if(mysql_num_rows($sql)==1){
mysql_query("UPDATE students SET pass='$npass' WHERE pass='$password2'");
mysql_query("UPDATE credits SET studentid='$npass' WHERE studentid='$password2'");
echo 'Your Password has been changed successfully!
';
}else{
echo 'Your original password is not correct
';
}
}
}
}
}
if($_POST['test']==2){
$email = formating($_POST['email']);
$sql = mysql_query("SELECT pass FROM students WHERE email='$email'");
if(mysql_num_rows($sql)==1){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}}
$title = 'Your NHS Password';
$post = 'Your password is "'.$pass.'". If you want to change it (DO NOT CHANGE IT IF YOU ALREADY HAVE CREDITS) go to http://www.dehs-nhs.org/changepass.html';
mail($email, $title, $post,
"From: DEHS NHS");
echo 'Your password has been sent to '.$email.'
';
}else{
echo 'Your email is not in our database
';
}
}
echo '
NOTE: If you already have credits, you will lose them if you change your password!
Fill out this form to change your password
';
echo '
Fill out this form to recover your password. This is safe to use if you already have credits! If your email is not correct email webmaster@dehs-nhs.org.
';
display_bottom();
?>