-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