Hey guys - I'm trying to make it where users can sign into my database and then if their password is approved, they'll be sent to another page. here's the login script i'm using
the rest of the page contains the html stuff to connect .. here it is
now after the person pushes Sign In, i want it to take them to /admin/insert.php. this isn't working for some reason. i have this header included at the top of every page i want to be password checked too...
do you have any ideas on how I can get these pages to redirect. currently when i type in the correct name/password, all that happens is that the page stays at login.php
thanks much in advance
cheers!
-------
Code:
<?php
//this initiates a session
session_start();
//see if there is a cookie that is both logged in the session we are in
if($_COOKIE['logedin'] == 'yes' || $_SESSION['logedin'] == 'yes') {
//if the cookie is there or the session is logged in , then include the header login.php
header("Location: login.php");
//exit successfully
exit();
}
// If the form was submited check if the username and password match
if($_POST['Submit']){
//assign a variable to the username the user input
$username = $_POST['user'];
//assign a password to the username the user input
$password = $_POST['pass'];
if ($username=="user" && $password=="pass"){
// If username and password is right , store the session in a cookie
setcookie ('logedin', 'Admin Access',time()+30000); // Set the length of the cookie to 30000
//Create the Session id's (as many as you want, can also do the same with cookied)
$_SESSION['logedin'] = ' Admin Access';
//close the database
@mysql_close();
// Redirect to the page
header("Location: /admin/insert.php");
//exit successfully
exit();
} else {
//print this to the screen
$error = 'Password and/or Username Not Valid, Please Try Again!';
//close the database
@mysql_close();
}
}
?>
Code:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="adminlogin" id="adminlogin">
<table width="30%" border="5" align="left" cellpadding="5" cellspacing="0">
<tr bgcolor="#000000">
<td colspan="2"><div align="center"><font color="#FFFFFF"><strong>PLEASE
LOG IN:</strong></font></div></td>
</tr>
<tr>
<td width="47%"><strong>Username:</strong></td>
<td width="53%"><input name="user" type="text" id="user" ></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input name="pass" type="password" id="pass" ></td>
</tr>
<tr>
<td colspan="2"><div align="center"><strong>
<input name="Submit" type="submit" id="Submit" value="Click Here To Sign-In">
</strong> </div></td>
</tr>
</table>
<table width="60%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="50"><div align="center"><strong><font color="#FF0000"><?php echo $error; ?></font></strong></div></td>
</tr>
</table>
</form>
now after the person pushes Sign In, i want it to take them to /admin/insert.php. this isn't working for some reason. i have this header included at the top of every page i want to be password checked too...
Code:
<?php
//this information is so everyone doesn't have access to changing records
if($_SESSION['logedin'] != 'Admin Access' || $_SESSION['logedin'] != 'Admin Access'){
header("Location: /anss/station_info/login.php");
exit();
} ?
do you have any ideas on how I can get these pages to redirect. currently when i type in the correct name/password, all that happens is that the page stays at login.php
thanks much in advance
cheers!
-------