this is what i want:
once the library administrator hits the "log in" button i want to redirect him/her a page where from they can do some administrative work - i.e. insert book (insertbook.php) , delete book (deletebook.php);
so what i m so far able to do is show them a welcome messege once they logged in as administrator.
here is the code...please take a look at - Here i have used comment to tell my requirement more clearly...it is near the welcome messege...
Code: Select all
<?php
<html>
<head>
<title>Login</title>
</head>
<body>
<?php
/* database connect script. */
require 'db_connect.php';
if($logged_in == 1)
{
die('You are already logged in,<b> '.$_SESSION['username'].'</b>. Go back <a href = "template2.php">HOME</a>.');
}
if (isset($_POST['submit']))
{
// if form has been submitted
/* check they filled in what they were supposed to and authenticate */
if(!$_POST['uname'] | !$_POST['passwd'])
{
die('You did not fill in a required field.');
}
// authenticate.
if (!get_magic_quotes_gpc())
{
$_POST['uname'] = addslashes($_POST['uname']);
}
$check = "SELECT username, password FROM users WHERE username = '".$_POST['uname']."'";
$result = mysql_query($check);
$num_rows = mysql_num_rows($result);
if (!($num_rows))
{
die('That username does not exist in our database.');
}
$info = mysql_fetch_Array($result);
// check passwords match
$_POST['passwd'] = stripslashes($_POST['passwd']);
$info['password'] = stripslashes($info['password']);
$_POST['passwd'] = md5($_POST['passwd']);
if ($_POST['passwd'] != $info['password'])
{
die('Incorrect password, please try again.');
}
/* if we get here username and password are correct,
register session variables and set last login time.*/
$date = date('m d, Y');
$update_login = mysql_query("UPDATE users SET last_login = '$date' WHERE username = '".$_POST['uname']."'");
$_POST['uname'] = stripslashes($_POST['uname']);
$_SESSION['username'] = $_POST['uname'];
$_SESSION['password'] = $_POST['passwd'];
// Remember Me cookie will be set after successful login
if (isset($_POST['remember_me'])) {
$time_expire = time()+31536000;
setcookie("uname", $_POST['uname'], $time_expire);
setcookie("passwd", md5($_POST['passwd']), $time_expire);
}
?>
<table border="0" width="100%">
<tr>
<td width="100%"><b>Logged in</b></td>
</tr>
</table>
<table border="0" width="100%">
<tr>
<td width="100%">
<form action="<?php echo $_SERVER['PHP_SELF']?>?var=logout" method="post">
<p><input type="submit" value="logout" name="logout"></p>
</form>
<p> </td>
</tr>
</table>
welcome //the welcome messege.....
//here i would like to redirect the user to a new page...how to do that? lets say i want
to redirect them to insert.php page.
<?php
}
else
{
// if form hasn't been submitted
?>
<!-- This is the first screen when a user sees when he is not logged in -->
<form action="<?php echo $_SERVER['PHP_SELF']?>?var=login" method="post">
<center>
<table width="250" border="1" cellspacing="0" cellpadding="4" bordercolor="#000000" bordercolordark="#000000" bordercolorlight="#000000" bgcolor="#FFFFFF" style="border-collapse: collapse" height="158">
<tr>
<td class="updatecontent" height="75">
<table border="0" width="100%">
<tr>
<td width="50%"><b>username</b></td>
<td width="50%"><input type="text" name="uname" maxlength="40"></td>
</tr>
<tr>
<td width="50%"><b>password</b></td>
<td width="50%">
<input type="password" name="passwd" maxlength="50">
</td>
</tr>
</table>
</td></tr>
<tr><td class="updatefooter" height="63">
<input type="Checkbox" name="Remember_Me"> <b>Remember Me </b><font color="#000000">[applicable
for private pc only]</font><br>
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}
?></center>
<p>
</body>
</html>
?>