please help me to put a pasword for this page

very simple, i recommend to user session for admin log in:


login.php:
Code:
<?php
ob_start();
if(!$_POST['user'] && !$_POST['pass'])
{
// your form here
}
else
{
           if($_POST['user'] == "admin" && $_POST['pass'] == "yourpass")
           {
                      $_SESSION['logon'] = true;

                       header("location: admin.php");
            }
            else
            {
             echo "Username or password are wrong. Please go back and check your details";
              }
   
}

ob_flush();
?>

admin.php:

Code:
<?php
ob_start();

if(!$_SESSION['logon'])
{
include("login.php"); // if your are not loged in it will print your the login page.
}
else
{

// if your are loged on, print your page here :P

}

ob_flush();
?>











hope it helps 8)
 
for more advanced systems i would have other recommendations: using sessions is needed but i would recommend using php sessions only for storing a speciall session id that will point to the session information stored in the database..

therefore database-based session management gives a much higher control over sessions and logged in users
 
Back
Top