user login in from MySql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

user login in from MySql

Post 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.
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post by Linkjames »

*Adds mysql_query to start of query*

*wanders off crying*
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

dude, u must query the DB first, writing $query won't do the job alone, try
$result = mysql_query($query);
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

yah, calling mysql_query, with the actual query helps... very true... ;)
Post Reply