-1
<?php
//Get Session
$getSession = isset($_SESSION['forum_user']) ? $_SESSION['forum_user'] : "";
//Login Script
$postLoginBtn = isset($_POST['forum_login_submit']) ? $_POST['forum_login_submit'] : "";
if ($postLoginBtn == "Login") {
$user = isset($_POST['forum_user']) ? $_POST['forum_user'] : "";
$pass = isset($_POST['forum_pass']) ? $_POST['forum_pass'] : "";
$pass = md5($pass);
$query = mysql_query("SELECT * FROM admin_users WHERE user_name='{$user}' and password='{$pass}'");
echo "SELECT * FROM admin_users WHERE user_name='{$user}' and user_password ='{$pass}'";
$count = mysql_num_rows($query);
//echo $count;
if ($count == 1) {
$_SESSION['forum_user'] = $_POST['forum_user'];
header("Location:admin.php");
} else {
echo "<script type='text/javascript'>";
echo "alert('Entered username and password is not matched. Please try again!!');";
echo "window.location='index.php';";
echo "</script>";
}
}
if ($getSession == "") {
?>
<div id="loginContainer">
<div id="loginDiv">
<div id="loginHeadingDiv">LOGIN PANEL</div>
<div id="loginFieldsDiv">
<form action="" method="post">
<table id="loginTable">
<tr>
<td>Username</td>
<td><input type="text" class="loginFields" name="forum_user" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" class="loginFields" name="forum_pass" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" id="loginSbmtBtn" value="Login" name="forum_login_submit" /></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php
} else {
echo "<script type='text/javascript'>";
echo "alert('Kindly login to enter the admin area.');";
echo "window.location='index.php';";
echo "</script>";
}
?>
我想登录,但我得到一个错误“警告:mysql_num_rows()期望参数1是资源,布尔给定login.php第15行”; .T已经尝试了很多,但无法解决请帮助我。无法在PHP中使用用户名和密码登录
感谢奔但是这不是我想做。 – pradeep 2014-12-13 07:42:55
这意味着querry cailed返回一个错误 – 2014-12-13 07:50:01