CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Authentication scrip problem

Print topic Send  topic

Author Message
Bill
Posted: 09/03/2002, 9:07 PM

Bill
Posted: 09/03/2002, 9:09 PM

I get this error
Warning: Supplied argument is not a valid MySQL result resource in /var/websites/agents.ultrafast.com.au/www/db_files/authmain.php on line 14

when I run this script
----------------------------------------------------
<?
session_start();

if ($userid && $password)
{
// if the user has just tried to log in

$db_conn = mysql_connect("localhost", "xxxxxx", "xxxxxx");
mysql_select_db("auth", $db_conn);
$query = "select * from Staff "
."where Uname='$userid' "
." and Pword=password('$password')";
$result = mysql_query($query, $db_conn);
if (mysql_num_rows($result) >0 )
{
// if they are in the database register the user id
$valid_user = $userid;
session_register("valid_user");
}
}
?>
<html>
<body>
<h1>Home page</h1>
<?

if (session_is_registered("valid_user"))
{
echo "You are logged in as: $valid_user <br>";
echo "<a href=\"logout.php\">Log out</a><br>";
}
else
{
if (isset($userid))
{
// if they've tried and failed to log in
echo "Could not log you in";
}
else
{
// they have not tried to log in yet or have logged out
echo "You are not logged in.<br>";
}

// provide form to log in
echo "<form method=post action=\"authmain.php\">";
echo "<table>";
echo "<tr><td>Userid:</td>";
echo "<td><input type=text name=userid></td></tr>";
echo "<tr><td>Password:</td>";
echo "<td><input type=password name=password></td></tr>";
echo "<tr><td colspan=2 align=center>";
echo "<input type=submit value=\"Log in\"></td></tr>";
echo "</table></form>";
}
?>
<br>
<a href="members_only.php">Members section</a>
</body>
</html>
------------------------------

Any Ideas???

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.