After Log in, Pull Course Information Help! Please
Results 1 to 6 of 6

Thread: After Log in, Pull Course Information Help! Please

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    7

    Unhappy After Log in, Pull Course Information Help! Please

    how do I fix this error?

    mysql_num_rows() expects parameter 1 to be resource, null given in /home/content/19/10458419/html/capstone/loginScript/indexTest.php on line 61

    My Code

    <?php
    }
    elseif(!empty($_POST['username']) && !empty($_POST['password']))
    {
    $username = mysql_real_escape_string($_POST['username']);
    $password = md5(mysql_real_escape_string($_POST['password']));

    $checklogin = mysql_query("SELECT * FROM schedule WHERE Username = '".$username."' AND Password = '".$password."'");

    if (mysql_num_rows($checkusername) > 0)
    {
    $row = mysql_fetch_array($checklogin);

    $email = $row['EmailAddress'];
    $courseNo = $row['courseNo'];
    $deptId = $row['deptId'];
    $callNo = $row['callNo'];
    $sectDays = $row['sectDays'];
    $sectStartTime = $row['sectStartTime'];
    $sectEndTime = $row['sectEndTime'];
    $roomNo = $row['roomNo'];
    $bldgId = $row['bldgId'];


    $_SESSION['LoggedIn'] = 1;

    echo "<h1>Success</h1>";
    echo "<p>We are now redirecting you to the member area.</p>";
    echo "<meta http-equiv='refresh' content='=2;indexTest.php' />";
    }
    else
    {
    echo "<h1>Error</h1>";
    echo "<p>Sorry, your account could not be found. Please <a href=\"indexTest.php\">click here to try again</a>.</p>";
    }
    }
    else
    {
    ?>


  2. #2
    Junior Member
    Join Date
    May 2013
    Posts
    7

    Angry if (mysql_num_rows($checkusername) ==1)this is where it keeps erroring

    <?php include "base.php"; ?>
    <?php
    $Today=date('y:m:d');
    $new=date('l, F d, Y',strtotime($Today));
    echo $new; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>User Management System</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    </head>
    <body>
    <div id="main">
    <?php
    if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))
    {
    ?>

    <!-- instructor information starts here-->

    <h1>Instructor Area</h1>
    <p>Thanks for logging in! You are Instructor <strong><?=$_SESSION['Username'] ?></strong><br/> <p>Here is your current schedule </p><br/>

    <table>
    <tr><td> <?=$_SESSION['courseNo'] ?></td></tr>
    <tr><td> <?=$_SESSION['deptId'] ?></td></tr>
    <tr><td> <?=$_SESSION['callNo'] ?></td></tr>
    <tr><td> <?=$_SESSION['sectDays'] ?></td></tr>
    <tr><td> <?=$_SESSION['sectStartTime'] ?></td></tr>
    <tr><td> <?=$_SESSION['sectEndTime'] ?></td></tr>
    <tr><td> <?=$_SESSION['roomNo'] ?></td></tr>
    <tr><td> <?=$_SESSION['bldgId'] ?></td></tr>
    </table>

    </p>




    <p>
    <p align="center"><a href="indexTest.php"></a></p></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>

    <!-- instructor info ends here-->

    <ul>
    <li><a href="logout.php">Logout.</a></li>
    </ul>

    <?php
    }
    elseif(!empty($_POST['username']) && !empty($_POST['password']))
    {
    $username = mysql_real_escape_string($_POST['username']);
    $password = md5(mysql_real_escape_string($_POST['password']));

    $checklogin = mysql_query("SELECT * FROM schedule WHERE Username = '".$username."' AND Password = '".$password."'");

    if (mysql_num_rows($checkusername) ==1)
    {

    $row = mysql_fetch_array($checklogin);

    $email = $row['EmailAddress'];
    $courseNo = $row['courseNo'];
    $deptId = $row['deptId'];
    $callNo = $row['callNo'];
    $sectDays = $row['sectDays'];
    $sectStartTime = $row['sectStartTime'];
    $nameInstruct = $row['nameInstruct'];
    $sectEndTime = $row['sectEndTime'];
    $roomNo = $row['roomNo'];
    $bldgId = $row['bldgId'];


    $_SESSION['LoggedIn'] = 1;

    echo "<h1>Success</h1>";
    echo "<p>We are now redirecting you to the member area.</p>";
    echo "<meta http-equiv='refresh' content='=2;indexTest.php' />";
    }
    else
    {
    echo "<h1>Error</h1>";
    echo "<p>Sorry, your account could not be found. Please <a href=\"indexTest.php\">click here to try again</a>.</p>";
    }
    }
    else
    {
    ?>

    <h1>Instructor Login</h1>

    <p>Thanks for visiting! Please either login below, or <a href="registerTest.php">click here to register</a>.</p>

    <form method="post" action="indexTest.php" name="loginform" id="loginform">
    <fieldset>
    <p>
    <label for="username">Username:</label>
    <input type="text" name="username" id="username" /><br />
    <label for="password">Password:</label>
    <input type="password" name="password" id="password" /><br />
    <input type="submit" name="login" id="login" value="Login" />
    </p>
    <p>&nbsp;</p>

    </fieldset>
    </form>
    <br/>

    <?php
    }
    ?>
    </div>
    </body>
    </html>

  3. #3
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,854
    Please read some of the FAQs, and put a bit more work into your posts. No-one is going to want to bother trawling through all that for you.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  4. #4
    Junior Member
    Join Date
    May 2013
    Posts
    7
    This is where it keeps erroring out
    if (mysql_num_rows($checkusername) ==1)

    sorry about the long code, I thought I was being thorough.

  5. #5
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,854
    But please read the FAQs. You'll see information about how to post code.

    Also, have you read the error message? It says that $checkusername is null. Read your own code and ask yourself why that might be.
    Last edited by Weedpacket; 05-05-2013 at 04:42 PM.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  6. #6
    Junior Member
    Join Date
    May 2013
    Posts
    7
    Thanks for the reply. I've actually inherited this code, the guy on my team just left, and I am a designer not a coder. I am trying to piece it all together, can you tell me what should go there? and if the rest of the code is valid?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •