I' trying to make a logon script for my site using $_SESSION to store a variable that identifies the user who is logged on.
I'm trying to use this code to generate a logon form if the session variable is empty:
But my problem is the form is always generated whether or not $_SESSION['grid'] exists.
I'm also having trouble with my sql queries that used to work fine until I introduced the session stuff:
For this:
I get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/miocene1/public_html/includes/selectusers.phpon line 8
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/miocene1/public_html/includes/selectusers.php on line 12
I'm trying to use this code to generate a logon form if the session variable is empty:
PHP:
<?php if(!$_SESSION['grid']){
echo "<p>Please Log in to access your account</p>";
echo "<form method=\"post\" action=\"loggedin.php\">";
echo "<table>";
echo "<tr><td>Group Name:</td><td><input name=\"group\" type=\"text\" /></td></tr>";
echo "<tr><td>Group Password:</td><td><input name=\"password\" type=\"password\" />";
echo "<tr colspan=2><td><input name=\"Submit1\" type=\"submit\" value=\"submit\" /></td></tr>";
echo "</table></form>";}
?>
But my problem is the form is always generated whether or not $_SESSION['grid'] exists.
I'm also having trouble with my sql queries that used to work fine until I introduced the session stuff:
For this:
PHP:
<?php
include("connection.php");
$groupid = $_SESSION['grid'];
$username = mysql_query("SELECT * FROM users WHERE group = $groupid");
$num_users = mysql_num_rows($username);
$i=0;
while($row = mysql_fetch_array($username))
{
$users[$i] = $row['username'];
$user_id[$i] = $row['id'];
$i++;
}
?>
I get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/miocene1/public_html/includes/selectusers.phpon line 8
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/miocene1/public_html/includes/selectusers.php on line 12