我为我的网站创建了一个登录表单,但目前它不起作用,我被定向到 invalid.php,这表明我的身份验证失败。
<?php
session_start();
include("scripts/dbconnect.php");
$numrows=0;
$password=$_POST['password'];
$email=$_POST['email'];
$query="select fname,lname,email from mayan_users where (password='$password' && email='$email')";
$link = mysql_query($query);
if (!$link) {
die('login error');
}
$numrows=mysql_num_rows($link);
if ($numrows>0){ // authentication is successfull
$row = mysql_fetch_array($link, MYSQL_ASSOC);
$_SESSION['user']['fname']=$row['fname'];
$_SESSION['user']['lname']=$row['lname'];
$_SESSION['user']['email']=$row['email'];
header("location:../index2.php");
} else {
header("location:../invalid.php"); // authentication was unsuccessfull
}
?>
这是我的登录表格
<div id="Loginform" style="background-color:fuchsia; width:100%">
<span id="logspan">
<input type="email" name="email" id="email" placeholder="Email" required />
<input type="password" name="password" id="password" placeholder="Password" required/>
<input type="button" name="submit" style="cursor:pointer" id="submit" value="Log In" onclick="logMeIn()" />
</span>
</div>