PHP密码更新表单

时间:2014-04-08 15:05:04

标签: php html mysql

出于某种原因,我可以让它找到数据并检查您是否提交了正确的旧密码,但它不会更新新的密码?我不确定接下来要做什么我已经尝试了一切......

    <?php
include 'header.php';
if (isset ($_POST['passupdate'])){
$pass = $_POST['pass'];

$opass = $_POST['opass'];

$db_passwordcheck = md5($salt.$opass);

$db_password = md5($salt.$pass);

$sql = mysql_query("SELECT * FROM members WHERE username='$username' AND password='$db_passwordcheck'"); 
        $login_check = mysql_num_rows($sql);

        if($login_check > 0){ 

    $updatepass = "UPDATE members SET password='$db_password' WHERE username=$username";
    $result = mysql_query($updatepass);
    $congrats = "password updated.";

}else{

$congrats = "wrong password try again...";
}
}

?>
<form class="form-1" method="POST">

            <label for="opassword">Old Password: </label>
            <input id="opass" type="password" name="opass" placeholder="old password" />

            <label for="password">New Password: </label>
            <input id="pass" type="password" name="pass" placeholder="new password" />

            <input type="submit" id="passupdate" name="passupdate" value="Update Password" class="btn right" />
<?php print($congrats);?>
    </form>

0 个答案:

没有答案