-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>";
}
?>

I am trying to login but I am getting an error " Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given login.php on line 15";.T have tried a lot but not able to solve please help me.

pradeep
  • 15
  • 4

1 Answers1

0

try this-->

    $res="write your select query here" ;
    $result=mysql_query($res) or die("query fail to execute".mysql_error());
    $total=mysql_num_rows($result );
    if( $total<0){
     echo "no row found";
     }
    else{
     while($row=mysql_fetch_array($result))
     {
   // some code}
mintra
  • 337
  • 1
  • 3
  • 17