我想知道我錯過了哪些錯誤。與會話登錄表單錯誤
我的形式會是這樣
<form id="myForm" action="loginAction" name="login" method="POST">
<p> <label class="inputField" > Email Address : </label> </p>
<p> <input class="registerField" id="emailid" name="email" required="required" type="text" placeholder="eg. [email protected]"/> <span class="warning" id="emailWarning"> </p>
<p> <label class="inputField" > Password : </label> </p>
<p> <input class="registerField" id="textpwd" name="password" required="required" type="password" placeholder="Your password"/> </p>
<p> <input name="submit" class="registerButton" type="submit" value="LOGIN"> </p>
loginAction.php低於
<?php
// Report all PHP errors
error_reporting(-1);
session_start();
include 'dbconnect.php';
$username = $_POST['email'];
$password = $_POST['password'];
$username = mysqli_real_escape_string(stripslashes($username));
$password = mysqli_real_escape_string(stripslashes($password));
$loginUser = " SELECT registerPassword, emailAddress FROM register_user
WHERE emailAddress = '$username' AND registerPassword = '$password'";
$loginSuccess = mysqli_query($mysqli, $loginUser) or die(mysqli_error($mysqli));
$loginRow = mysqli_num_rows($loginSuccess);
if($loginRow == 1) {
// $_SESSION['login_user'] = $username;
echo "SUCCESSFUL LOGIN";
//header ("Location: index");
} else {
echo "YOU WRONG";
}
mysqli_close($mysqli);
?>
答案是你錯了即使密碼和下面的代碼電子郵件是一樣的。我知道我還沒有完成會議,但這不能登錄,所以我不能做更多的會話。
你進入你的分貝相同的憑據? – Tushar 2014-11-05 09:25:37
是的,我認爲它是@TusharGupta – Anthosiast 2014-11-05 09:27:01
首先將php代碼放在一個'if(isset($ _ POST ['submit'])){}'中,以確保表單正常工作,然後打印出你得到的表單數據庫和什麼值依賴'$ loginRow' ... – 2014-11-05 09:27:56