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
https://forums.phpfreaks.com/topic/244177-solved-login-not-saving/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.