Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://example.com/login-system/reset.php?email=example%40gmail.com&key=523db8c57a3d17d0860fa705c4c24ec62efc0c68f2f1443e39938361424099f1
- ¡Ingresó una URL inválida para restablecer la contraseña!
- <?php
- session_start();
- include "require.php";
- if (isset($_GET['email']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/', $_GET['email'])) {
- $email = $_GET['email'];
- }
- if (isset($_GET['key']) && (strlen($_GET['key']) == 64)) {
- $key = $_GET['key'];
- }
- if (isset($email) && isset($key)) {
- //$email = $con->escape_string($_GET['email']);
- //$key = $con->escape_string($_GET['key']);
- $active_defaul = 1;
- $stmt = $con->prepare("SELECT * FROM users WHERE email=? AND email_code=? AND active=?");
- $stmt->bind_param("ssi",$email,$key,$active_defaul);
- $stmt->execute();
- $stmt->store_result();
- //if ($result->num_rows == 0 )
- if ($stmt->num_rows>0) {
- echo "¡Ingresó una URL inválida para restablecer la contraseña!";
- } else {
- echo '
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form action="reset_password.php" method="post">
- <label>New Password</label>
- <input type="password" name="password" autocomplete="off"/>
- <label>Confirm New Password</label>
- <input type="password" name="password_again" autocomplete="off"/>
- <input type="hidden" name="email" value="'.$email.'">
- <input type="submit" name="form_reset" value="Guardar contraseña" />
- </form>
- </body>
- </html>';
- }
- } else {
- echo "¡Acceso denegado!";
- }
- ?>
- session_start();
- include "require.php";
- if (isset($_POST['form_reset'])) {
- $email = $_POST['email'];
- $password = $_POST['password'];
- $hash_password = password_hash($password, CRYPT_BLOWFISH);
- $stmt = $con->prepare("UPDATE users SET password= ? WHERE email=? OR username=?");
- $stmt->bind_param("sss", $hash_password,$email,$email);
- if($stmt->execute()){
- header("location: correcto.php")
- } else {
- header("location: error.php");
- }
- }
Add Comment
Please, Sign In to add comment