CMS ultra léger au style oldschool, projet de la communauté Kalaïn Hundin.

lost2.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. session_start();
  3. require_once('config.php');
  4. $page_name='Password forgotten';
  5. include_once('top.php');
  6. //récupération du formulaire
  7. $email=formulaires($_POST['email']);
  8. $username=formulaires($_POST['username']);
  9. if(!$email)
  10. {
  11. echo"Empty E-mail.<br /><a href='#' onClick='history.back()'>Back</a></center>";
  12. include_once('bottom.php');
  13. return FALSE;
  14. }
  15. if(!$username)
  16. {
  17. echo"Empty username.<br /><a href='#' onClick='history.back()'>Back</a></center>";
  18. include_once('bottom.php');
  19. return FALSE;
  20. }
  21. $reponse_username=mysql_query("SELECT username FROM user WHERE username='$username'") or die ('error : '.mysql_error());
  22. $count_username=mysql_num_rows($reponse_username);
  23. if($count_username == 0)
  24. {
  25. echo"Invalid username.<br /><a href='#' onClick='history.back()'>Back</a>";
  26. include_once('bottom.php');
  27. return FALSE;
  28. }
  29. $reponse_email=mysql_query("SELECT email FROM user WHERE email='$email'") or die ('error : '.mysql_error());
  30. $count_email=mysql_num_rows($reponse_email);
  31. if($count_email == 0)
  32. {
  33. echo" Invalid E-mail.<br /><a href='#' onClick='history.back()'>Back</a>";
  34. include_once('bottom.php');
  35. return FALSE;
  36. }
  37. $existe=mysql_query("SELECT email FROM user WHERE email='$email' AND username='$username'") or die ('error : '.mysql_error());
  38. $test=mysql_num_rows($existe);
  39. if($test == 0)
  40. {
  41. echo"E-mail and Username don't match.<br /><a href='#' onClick='history.back()'>Back</a>";
  42. include_once('bottom.php');
  43. return FALSE;
  44. }
  45. for ($ligne=0;$ligne<10;$ligne++) //Création d'un mot de passe aléatoire
  46. {
  47. @$passwd.=substr('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN',(rand()%(strlen('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN'))),1);
  48. }
  49. mail("$email", "".$website_name." - Forgotten password" , "Hello, this is your new password : ".$passwd."", "From: ".$blog_email."");
  50. $passwd=md5($passwd);
  51. mysql_query("UPDATE user SET pass='$passwd' WHERE email='$email'") or die ('error : '.mysql_error());
  52. echo 'An E-mail has been sent to your mailbox with your new password';
  53. ?>