Hi all! I have this login script which is very simple that logs people in and starts a session if the password and user are correct. But whats happening is after you have logged in and navigate away from the main admin page say add an entry or make an edit then go back to the main admin page it will ask you to login again. Is there away to keep the person logged in permantly or until they say logout? Here is the script I'm using:
<?php
session_start();
//Has a session been started yet?
if (!isset($_SESSION['name']))
{
// If no previous session has started has the user submitted the login form?
if (isset($_POST['username']))
{
$username = $_POST['username'];
$password = $_POST['password'];
// Connect to MySQL database
require_once('../../Connections/News.php');
$query = "SELECT first FROM login WHERE username ='$username' AND password ='$password'";
$result = mysql_query($query);
//if user is found assign session variables
if (mysql_numrows($result)== 1)
{
$_SESSION['name'] = mysql_result($result,0,"first");
}
//if user has not logged in show login form
}
else
{
echo "
<link href='/Beacon/New_Site/adminstyle.css' rel='stylesheet' type='text/css'>
<title>New Beacon Admin Page</title>
<table width='center' cellspacing='1' cellpadding='1' class='boxborder' align='center'>
<tr>
<td class='text'>Login Required</td>
</tr>
</table>
<form action='$_SERVER[PHP_SELF]' method='post'>
<table width='center' cellspacing='1' cellpadding='1' class='boxborder' align='center'>
<tr>
<td class='text' align='center'><br/>
Username: <input name='username' size='20' />
Password: <input type='password' name='password' size='20' />
<input type='submit' name='login' value='Log in' /><br /><br />
</td>
</tr>
</table>
</form>
";
}
}
else
{
// Display the Admin page
}