i have the index page where the login form is.But i have a problem because when i type the user and pass it relocated me in the same page-index.php.
i must to mansion, that i need a simple php login,not with database.
So i have a index page and when i login i want to give me IndexAdmin.php.I dont understand,it seem everything is OK,but still doesnt work.
here is the code:
<?php
session_start();
$_SESSION['logged'] = 0;
if (isset($_POST['submit']))
{
if($_POST['username'] == "aaa" or $_POST['password'] == "aaa")
{
$_SESSION['logged'] =1;
header ("Location:IndexAdmin.php");
}
else
{
?>
<html>
<head>
......>html code
<form action="Index.php" method="post">
<input type="hidden" name="redirect" value="<?php echo $_POST['redirect']; ?>">
<input type="text" name="username" size="10" tabindex="101"><br />
<input type="password" name="password" size="10" tabindex="102">
<input type="Submit" value="submit" name="Submit" size="10" tabindex="103"><br />
</form>
.....>here is the rest of the html code that is not important
<?php
}
}
else
{
?>
<html>
<head>
......html code
<form action="Index.php" method="post">
<input type="hidden" name="redirect" value="<?php echo $_GET['redirect']; ?>">
<input type="text" name="username" size="10" tabindex="101"><br />
<input type="password" name="password" size="10" tabindex="102">
<input type="Submit" value="submit" name="Submit" size="10" tabindex="103"><br />
</form>
......html code
<?php
}
?>
</body>
</html>
with the dots i mean that there is the rest of the html code like images etc...
and in the IndexAdmin.php page i have include "inc.auth.php" because if the user tries to type indexAdmin.php he will get that he must login to see this page
here is the inc.auth.php code
<?php
session_Start();
if ($_SESSION['logged'] != 1)
{
$redirect = $_SERVER['PHP_SELF'];
header("Refresh: 5; URL=index.php?redirect=$redirect");
echo "u cant see this page, you must login<BR>";
echo "you will be redirected to the main page<br>";
echo "(if your browser doenst support this , <a href=\"index.php?redirect=$redirect\">click here</a>)";
die();
?>
|