Forgot Password [pt2]


Insert this in your database
PHP Code
  1. ALTER TABLE `members` ADD `pincode` INT( 3 ) NOT NULL DEFAULT '123';

Then create pwdreminder.php
PHP Code
  1. <?PHP
  2. session_start(); //allows session
  3. include('config.php');
  4. /*
  5. Forgot Password script
  6. */
  7. if ($_POST['Submit']) //Proceed if the submit button was pressed.
  8. {
  9. $Username = htmlspecialchars($_POST['username']); //Variable that contains the posted username.
  10. $Pincode = htmlspecialchars($_POST['pincode']); //Variable that contains the posted username.
  11. if (empty($Username)) //If the username field was left empty exit the script(with reason).
  12. {
  13. die("Username field blank");
  14. }
  15. if (empty($Pincode)) //If the Pincode field was left empty exit the script(with reason).
  16. {
  17. die("Pincode field blank");
  18. }
  19. $Search_Query = "SELECT `email` FROM `members` WHERE `username` = '$Username' && `pincode` = '$Pincode'";
  20. $Search_User = mysql_query($Search_Query) or die(mysql_error()); //This will search for the row that matches the username given.
  21. if (mysql_num_rows($Search_User) == 0) //If no data was returned we exit(with reason), because the username didn't match any in the database.
  22. {
  23. die("Username or Pincode incorret");
  24. }
  25.  
  26. $DB_Results = mysql_fetch_array($Search_User); //Fetch the("Email") results from the query.
  27. $Email = $DB_Results['email']; //I'm putting the email address in it's own variable, just cause i wanna :P
  28.  
  29. $New_Password = str_shuffle('D4gh7g55CdoP'); //Generates a password for the user.
  30. usleep(600000);
  31. //Replace "email@yoursite.com" with your email address. Explanation: mail("RECEIVER EMAIL", "MESSAGE", "YOUR EMAIL")
  32. mail($Email, 'Password Recovery', 'You requested a new password, Your New Password is '.$New_Password.'', 'staff@gbt91.net');
  33. $New_Password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($New_Password)))))))); //The password will be hashed before inserted into the database
  34. $Update_Password_Query = "UPDATE `members` SET `password` = '$New_Password' WHERE `email` = '$Email'"; //Query information for password update
  35. $Update_Password = mysql_query($Update_Password_Query) or die(mysql_error()); //Updates the current password with the NEW one.
  36. die("New Password Sent"); //If everything runs smoothly we display a success message to the user
  37. } else {
  38. //Display the form(HTML)
  39. ?>

ok that's all folks, this is just a more simple way for password reminder since Skill's have a lot of errors meanwhile check the addon :P
cya
gbt91's Avatar
Author:
Views:
2,261
Rating:
Posted on Tuesday 8th April 2008 at 01:48 AM
UrbanTwitch
UrbanTwitch's Avatar
LOLOLOLOL> Love how people post tutorials that don't work... <_<
Posted on Friday 2nd November 2007 at 07:39 AM
Liquidsteel
Liquidsteel's Avatar
Doesnt work. :)