I have a form and I want the users on it, to be able to login, and go to a admin page, it does. But if someone who is not logged in trys to go to that page, I want it to ask them for username and password, but not for the people logged in. I just need to protect 4-6 pages like this. Do you get what I mean?
My login script is :
Code: Select all
<?
if (isset($_POST['user']) && isset($_POST['pass'])){
if (($_POST['user']=='nick' && $_POST['pass']=='itelluwht') || ($_POST['user']=='nicky' && $_POST['pass']=='0319')){
include('/home/muot/public_html/pages/adminREDIRECT.php'); echo "<html><font color=green size=4>SUCCESS!</font></html>";
} else {
$error = "<div align=center><font size=-1 color=red>WRONG USERNAME OR PASSWORD</FONT></div>";
echo "$error";
}
}
$form = "
<html>
<body><div align=center><form action=login.php method=post><font size=2><b>Username:
<input type=text size=10 maxlength=10 name=user><br>
<font size=2><b>Password:
<input type=password size=10 maxlength=10 name=pass><br><input type=submit value=Login.>
</form>
</div></body></html>";
echo "$form";
?>Code: Select all
<HTML>
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=admin.php">
</html>Code: Select all
<?
blank
?>But what I need to do is just make those pages protected, and only viewable by the people that are logged on.
I can do this with sessions, but I dont get how to use them, I looked at many tutorials on it, and couldn't figure out any of it. Is it possible to do with IF statements?
Thank You