第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 php 在 pgadmin 上更改密碼時出現(xiàn)問題

使用 php 在 pgadmin 上更改密碼時出現(xiàn)問題

PHP
蕪湖不蕪 2023-03-04 16:21:58
我正在編寫一個 PHP 文件以允許用戶更改密碼,但我遇到了一個奇怪的問題。我需要舊密碼來確認(rèn)帳戶和新密碼。鑒于憑據(jù)正確,此頁面總是返回用戶密碼不正確,因此返回第 12 行“舊密碼錯誤”中的回顯。如果我在 pgAdmin 查詢工具中啟動“select * from utente”來查看密碼,我在密碼框中看不到任何變化。然后,如果我返回表單更改密碼,如果我在舊密碼框中輸入我之前想更改的新密碼,但似乎沒有被接受,因為以前沒有識別出舊密碼,程序成功。我發(fā)誓我不明白為什么。我認(rèn)為這是 md5 中的錯誤,但它也不適合 sha1。我知道兩者都不安全,但現(xiàn)在我必須使用其中之一。我該如何解決?提前致謝<?php    $dbconn = pg_connect("host=localhost port=5432 dbname=progetto user=postgres password=password")    or die('Could not connect:' . pg_last_error());    if(!(isset($_POST['changeButton']))){        header("Location: utente.php");    }else{        $email = $_COOKIE["cookieEmail"];        $oldPassword = sha1($_POST['oldpassword']);        $q1="select * from utente where email = $1 and password = $2";        $result=pg_query_params($dbconn,$q1,array($email, $oldPassword));        if($line=pg_fetch_array($result ,null ,PGSQL_ASSOC)){            echo "<h1>Old password wrong</h1>            <a href=formCambiaPassword.php>Click here</a>";        }else{            $newPassword = sha1($_POST['newpassword']);            $q2 = "update utente set password=$1 where email=$2";            $result=pg_query_params($dbconn, $q2, array($newPassword, $email));            if($result==true){                $q3="select * from utente where email = $1 and password = $2";                $result=pg_query_params($dbconn,$q3,array($email, $newPassword));                if($line=pg_fetch_array($result ,null ,PGSQL_ASSOC)){                    echo "<h1>Error</h1>                    <a href=formCambiaPassword.php>Click here</a>";                }else{                    header("Location: utente.php");                }            }else{                echo "<h1>Error 2</h1>                        <a href=formCambiaPassword.php>Click here</a>";            }        }    }?>
查看完整描述

1 回答

?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗 獲得超9個贊

您的 if 語句在應(yīng)該檢查 false 時正在尋找 true。


if(!pg_fetch_array($result ,null ,PGSQL_ASSOC)){

您的代碼應(yīng)如下所示:


<?php

$dbconn = pg_connect("host=localhost port=5432 dbname=progetto user=postgres password=password")

or die('Could not connect:' . pg_last_error());

if(!(isset($_POST['changeButton']))){

    header("Location: utente.php");

}else{

    $email = $_COOKIE["cookieEmail"];

    $oldPassword = sha1($_POST['oldpassword']);

    $q1="select * from utente where email = $1 and password = $2";

    $result=pg_query_params($dbconn,$q1,array($email, $oldPassword));

    if(!pg_fetch_array($result ,null ,PGSQL_ASSOC)){

        echo "<h1>Old password wrong</h1>

        <a href=formCambiaPassword.php>Click here</a>";

    }else{

        $newPassword = sha1($_POST['newpassword']);

        $q2 = "update utente set password=$1 where email=$2";

        $result=pg_query_params($dbconn, $q2, array($newPassword, $email));

        if($result==true){

            $q3="select * from utente where email = $1 and password = $2";

            $result=pg_query_params($dbconn,$q3,array($email, $newPassword));

            if($line=pg_fetch_array($result ,null ,PGSQL_ASSOC)){

                echo "<h1>Error</h1>

                <a href=formCambiaPassword.php>Click here</a>";

            }else{

                header("Location: utente.php");

            }

        }else{

            echo "<h1>Error 2</h1>

                    <a href=formCambiaPassword.php>Click here</a>";

        }

    }

}

?>


查看完整回答
反對 回復(fù) 2023-03-04
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號