Authentication area
Posted: Sun Feb 15, 2009 6:42 am
i tried understand how sessions work on secured area but cant.
I have 2 pages
secure1.php
secure2.php
what is the part of php that you will include in that 2 pages
that do
if (the user have set the username and password and they are right)
you can see the rest of that page
else
access denied
you must fill your username and pass on that form
<form>....</form>
i tryed to make an auth.inc.php
that have that code but ofc dont do what i want
ofcourse that code dont work and its refresh my page all time liek a counter
i hope you can understand what is my point here.thnx in advanced
I have 2 pages
secure1.php
secure2.php
what is the part of php that you will include in that 2 pages
that do
if (the user have set the username and password and they are right)
you can see the rest of that page
else
access denied
you must fill your username and pass on that form
<form>....</form>
i tryed to make an auth.inc.php
that have that code but ofc dont do what i want
Code: Select all
<?php
session_start();
$name = "user";
$pass = "pass";
if($_POST){
$_SESSION['username']=$_POST["username"];
$_SESSION['password']=$_POST["password"];
}
if($_SESSION['username'] == "user" AND $_SESSION['password'] == "pass")
{
$_SESSION['sec'] = "yes";
header("Location: secure1.php");
}
else
{
?>
</head>
<body>
<form id="form1" name="form1" method="post" action="<?PHP echo $PHP_SELF; ?>">
<p>username:
<label>
<input type="text" name="username" id="username" />
</label>
</p>
<p>password:
<label>
<input type="text" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</p>
</form>
</body>
</html>
<?php
}
exit;
?>
i hope you can understand what is my point here.thnx in advanced