cambiarcontraseña.php
- Reemplazar
AND
con,
entrepassword
&repassword
. - Eliminar
'
en la columna nombreemail
. - Cambiar
'email'=$result1
aemail='$email'
Cambiar
$query = mysql_query("update registered SET password = '$password' AND repassword ='$repassword' WHERE 'email'=$result1");
a
$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");
Para requisitos del usuario.
Dado que está pasando un correo electrónico a changepassword.php
.Tienes que crear un hidden field
para email
, que se enviará a forgottenpassword.php página.
Comprueba la conexión de tu base de datos. Y verifique si todos los nombres de las columnas están escritos correctamente.
Utilice este código tal como está.
Cambiar Contraseña.php
<form method="POST" action="forgotten.php" id="myform">
<input type='hidden' value="<?php echo $_GET['email'];?>" name='email'>
<div class="form-group">
<label for="psw"><span class="glyphicon"></span> Password</label>
<input id="password" class="form-control" type="password" name="password" placeholder="Enter password here" required/>
</div>
<div class="form-group">
<label for="rpsw"><span class="glyphicon"></span>Confirm Password</label>
<input id="repassword" class="form-control" type="password" name="repassword" placeholder="Retype password here" required/>
</div>
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Create New Password</button>
</form>
olvidado.php
<?
$connection = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("db_name", $connection);
$email=$_POST['email'];
$password=$_POST['password'];
$repassword=$_POST['repassword'];
$sql1="SELECT * FROM registered WHERE email ='$email'";
$result1=mysql_query($sql1);
$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");
if($query)
{
$to = $email;
$from = '[email protected]';
$subject="Password Changed";
$message.="your password has been changed successfully. ";
$success = mail($to, $subject, $message);
echo "Password has been changed successfully";
}
?>