Jump to content

[SOLVED] 'Login' not saving


dominic600

Recommended Posts

okay, so the problem I am having is that when i log in, i shouldnt be able to keep logging it and it keep telling me im loged in.

 

like it should be that when i log in and im already loged in that it should read out "you are already loged in" but it does not do that.

 

it was working correctly 2 night ago.

 

heres the login.php code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>1st Gen Cummins Blog | Login</title>
<link href='main.css' rel='stylesheet' type="text/css"></link>
</head>
<body>
<div id='header'><div id='headercnt'>1990 Dodge Cummins Turbo Diesel</div><div>
<div id='content'>
<hr />
<table border=0  width=1000 height=40>
<TR height=40> <TD colspan="2"><center>Youtube 	| 	Contact Me	 | 	Pictures 	| <a href='register.php'>Register</a> </center></TD> </TR> 
</table>

<hr />
<?php
$form = "<form action='login.php' method='post'> 
<center><table>
<tr>
	<td>Username:</td>
	<td><input type='text' name='username' class='textbox'></td>
</tr>
<tr>
	<td>Password:</td>
	<td><input type='password'	name='password' class='textbox'></td>
</tr>
<tr>
	<td></td>
	<td><input type ='submit' name='loginbtn' value='Login' class='button'></td>
</tr>
</table></center>
</form>";

if ($_POST['loginbtn']){
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);

if($username && $password){
	require("scripts/connect.php");

	$pass = md5(md5($password));
	$query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$pass'") or die(mysql_error());
	$numrows = mysql_num_rows($query);

	if ($numrows == 1){
		$row = mysql_fetch_assoc($query);
		$dbid = $row['id'];
		$dbuser = $row['username'];

		$date = ("F d, Y");
		mysql_query("UDATE users SET last_login='$date' WHERE id='$dbid'");

		$_SESSION['user'] = $dbuser;
		$_SESSION['userid'] = $dbid;

		echo "You are now loged in.<a href='index.php'> Click here </a>to return Home.";
	}	
	else
		echo "Your Username and/or Password are incorrect.";
}
else
	echo "You did not fill in the correct fields.";
}
else
echo "$form";
?>
<hr />
</div>
<div id='footer'></div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.