Page 1 of 1

user login in from MySql

Posted: Sat Sep 27, 2003 3:13 pm
by Linkjames
I seem to be missing somthing in my code, as I always get 'Not logged in'

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<? // First part of script time script ?>
<?PHP include("includes/exetime1.php"); ?>
<?PHP include("template/textcolour.php"); ?>
<body bgcolor="<?php echo $bgcolor ?>" text="<?php echo $text ?>" link="<?php echo $link ?>" vlink="<?php echo $vlink ?>" alink="<?php echo $alink ?>">
<?PHP include("template/tablestart.php"); ?>
<?PHP include("template/font.php"); ?>
<FONT face="<?php echo $face ?>" size="<?php echo $size ?>">
<form name="form1" method="post" action="login2.php">
  <p>Username
    <input name="username" type="text" id="username">
  </p>
              <p>Password 
                <input name="password" type="password" id="password">
              </p>
              <p>
                
              </p><input type="submit" name="Submit" value="Submit">
</form>
<p>&nbsp;</p>

<? // Second part of script time script ?>
<?PHP include("includes/exetime2.php"); ?>
<?PHP include("template/tableend.php"); ?>
</font>
</body>
</html>
This is the form for entering details

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<? // First part of script time script ?>
<?PHP include("includes/exetime1.php"); ?>
<?PHP include("template/textcolour.php"); ?>
<body bgcolor="<?php echo $bgcolor ?>" text="<?php echo $text ?>" link="<?php echo $link ?>" vlink="<?php echo $vlink ?>" alink="<?php echo $alink ?>">
<?PHP include("template/tablestart.php"); ?>
<?PHP include("template/font.php"); ?>
<FONT face="<?php echo $face ?>" size="<?php echo $size ?>">
<?PHP
//Connect to MySql
include("includes/connect.php");
//Select Database
include("includes/dbselect.php");
$username = $_POST['username'];
$password = md5($_POST['password']);
$result = ("SELECT id FROM users WHERE username = '$username' AND password = '$password'"); 
if(mysql_num_rows($result) == 1) { 
echo 'Logged in<P>';
}
else
{
echo 'Not Logged in<P>';
}

?>


<? // Second part of script time script ?>
<?PHP include("includes/exetime2.php"); ?>
<?PHP include("template/tableend.php"); ?>
</font>
</body>
</html>
Anyone see whats wrong with it? I am assuming its my password checking, but I can't figure out why...

Yes, I'm sure the username and pwd are accurate.

Posted: Sat Sep 27, 2003 3:51 pm
by Linkjames
*Adds mysql_query to start of query*

*wanders off crying*

Posted: Sat Sep 27, 2003 8:02 pm
by Cruzado_Mainfrm
dude, u must query the DB first, writing $query won't do the job alone, try
$result = mysql_query($query);

Posted: Sun Sep 28, 2003 2:06 am
by JAM
yah, calling mysql_query, with the actual query helps... very true... ;)