Hi there all i got this code for my lost password option goes like this : <? include 'db.php'; switch($_POST['recover']){ default: include 'lostpsw.php'; break; case "recover": recover_pw($_POST['email_address']); break; } function recover_pw($email_address){ if(!$email_address){ echo "You forgot to enter your Email address"; include 'lostpsw.php'; exit(); } // quick check to see if record exists $sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'"); $sql_check_num = mysql_num_rows($sql_check); if($sql_check_num == 0){ echo "No records found matching your email address<br />"; include 'lostpsw.php'; exit(); } // Everything looks ok, generate password, update it and send it! function makeRandomPassword() { $salt = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } $random_password = makeRandomPassword(); $db_password = md5($random_password); $sql = mysql_query("UPDATE users SET password='$db_password' WHERE email_address='$email_address'"); $subject = "Your Password at The Truth Discovered!"; $message = "Hi, we have reset your password. New Password: $random_password http://www.thetruthdiscovered.com/login.php Thanks! The Webmaster This is an automated response, please do not reply!"; mail($email_address, $subject, $message, "From: The Truth Discovered Webmaster< admin@mydomain.com>\n X-Mailer: PHP/" . phpversion()); echo "Your password has been sent! Please check your email!<br />"; include 'login.php'; } ?> PHP: the form is here : <?php include 'header.php'; ?> <center> <p align="center"><font face="Calligraphic" size="5" font color="white">New Password Request</font></p> <form action="lost_pw.php" method="post"> <font face="Calligraphic" font color='white' size="4"> Email Address:<font color='white'>*</font> <input type=text name='email_address' size=30><br><br><br> <input type="submit" value="Get Password" name="recover"> </form> </center> <br><br> <?php include 'footer.php'; ?> PHP: can someone please tell me what im doing wrong? when you enter your email address , and hit get password , it flashes, does nothing and stays on the form page ! no errors either! Help !! please THank you Elaine
I think it should be like this case "recover": $email_address=$_POST['email_address'] recover_pw($email_address); break; Code (markup):
when i changed that i get the error : Parse error: parse error, unexpected T_STRING in /home/www/thetruthdiscovered.com/lost_pw.php on line 9 any ideas? Elaine
oh yea ! k i changed it but now it is just flashing the page and doing nothing ! is there another way of requesting a new password instead of this way? ELaine