-1
昨晚它工作正常,現在我得到undefined errors
所有我的變量來自數據庫。如果我在while
循環後回顯變量,它們在那裏,但是一旦它們碰到if
,我會得到未定義的錯誤。while循環不返回結果PHP/MySQL
<?php
session_start();
include "connect.php";
include "report_errors.php";
$name = $_POST['name'];
$password = $_POST['password'];
$sql = $db->prepare("SELECT * FROM admin where username = :name AND
password = :password");
$sql->bindValue(':name', $name);
$sql->bindValue(':password', $password);
$sql->execute();
while($row = $sql->fetch())
{
$dbname = $row['username'];
$dbpass = $row['password'];
$dbemail = $row['email'];
}
if($name == $dbname && $password == $dbpass)
{
$_SESSION['loggedin'] = "yes";
$_SESSION['name'] = $name;
$_SESSION['pass'] = $password;
$_SESSION['email'] = $dbemail;
$url = "Location: yackimo_register_form.php";
header($url);
exit;
}
if($name == $dbname && $password != $dbpass)
{
$error = "invalidPassword";
$url = "Location: login.php?error=$error";
header($url);
exit;
}
**警告**你應該在你的分貝中加密你的密碼。 –
我知道驗證。這只是起牀和走的骨幹 – rogerthat
你是否嘗試打印出錯誤? 'PDO'可能提供某種類型的錯誤報告**(我使用mysqli)**。在execute()之前和之後''回顯''。 – CodeAngry