sql >> Database teknologi >  >> RDS >> Mysql

Sådan opdaterer du glemt adgangskode ved at sende en e-mail i mysql php

changepassword.php

  1. Erstat AND med , mellem password &repassword .
  2. Fjern ' i kolonnenavn email .
  3. Skift 'email'=$result1 til email='$email'

Skift

$query = mysql_query("update registered SET password = '$password' AND repassword ='$repassword' WHERE 'email'=$result1");

til

$query = mysql_query("update registered SET password = '$password', repassword ='$repassword' WHERE email='$email'");

Til brugerens krav.

Siden sender du e-mail til changepassword.php .Du skal oprette ét hidden field til email , som vil blive sendt til forgottenpassword.php side.

Tjek din databaseforbindelse. Og krydstjek, om alle kolonnenavne er skrevet korrekt.

Brug denne kode, som den er.

ChangePassword.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>

forgotten.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";
}
?>


  1. MYSQL slette alle resultater med count(*)=1

  2. er der nogen måde at logge alle mislykkede sql-sætninger i oracle 10g

  3. MySQL- Wamp-serveren fungerer ikke efter win10-opgradering

  4. Dato/tidsstempel for at registrere, hvornår en post blev tilføjet til tabellen?