Guest User

Untitled

a guest
Aug 28th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. http://example.com/login-system/reset.php?email=example%40gmail.com&key=523db8c57a3d17d0860fa705c4c24ec62efc0c68f2f1443e39938361424099f1
  2.  
  3. ¡Ingresó una URL inválida para restablecer la contraseña!
  4.  
  5. <?php
  6. session_start();
  7. include "require.php";
  8.  
  9. if (isset($_GET['email']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/', $_GET['email'])) {
  10. $email = $_GET['email'];
  11. }
  12. if (isset($_GET['key']) && (strlen($_GET['key']) == 64)) {
  13. $key = $_GET['key'];
  14. }
  15.  
  16. if (isset($email) && isset($key)) {
  17. //$email = $con->escape_string($_GET['email']);
  18. //$key = $con->escape_string($_GET['key']);
  19. $active_defaul = 1;
  20.  
  21. $stmt = $con->prepare("SELECT * FROM users WHERE email=? AND email_code=? AND active=?");
  22. $stmt->bind_param("ssi",$email,$key,$active_defaul);
  23. $stmt->execute();
  24. $stmt->store_result();
  25. //if ($result->num_rows == 0 )
  26. if ($stmt->num_rows>0) {
  27. echo "¡Ingresó una URL inválida para restablecer la contraseña!";
  28. } else {
  29. echo '
  30. <!DOCTYPE html>
  31. <html>
  32. <head>
  33. <title></title>
  34. </head>
  35. <body>
  36. <form action="reset_password.php" method="post">
  37. <label>New Password</label>
  38. <input type="password" name="password" autocomplete="off"/>
  39. <label>Confirm New Password</label>
  40. <input type="password" name="password_again" autocomplete="off"/>
  41. <input type="hidden" name="email" value="'.$email.'">
  42. <input type="submit" name="form_reset" value="Guardar contraseña" />
  43. </form>
  44. </body>
  45. </html>';
  46. }
  47.  
  48. } else {
  49. echo "¡Acceso denegado!";
  50. }
  51. ?>
  52.  
  53. session_start();
  54. include "require.php";
  55.  
  56. if (isset($_POST['form_reset'])) {
  57. $email = $_POST['email'];
  58. $password = $_POST['password'];
  59.  
  60. $hash_password = password_hash($password, CRYPT_BLOWFISH);
  61.  
  62. $stmt = $con->prepare("UPDATE users SET password= ? WHERE email=? OR username=?");
  63. $stmt->bind_param("sss", $hash_password,$email,$email);
  64. if($stmt->execute()){
  65. header("location: correcto.php")
  66. } else {
  67. header("location: error.php");
  68. }
  69.  
  70. }
Add Comment
Please, Sign In to add comment