Jump to content

[SOLVED] i need help more than ever PLEASE HELP


jeppers

Recommended Posts

can any one give me a script which will show me how session control works... i have been confused for along time so this is my last chance to it before i have to hand my project in.... it sad that i have brought my self  to this level but it too hard too late

 

thanks peeps i hope you can and will help i am so stuck 

fair enough

 

well just this then

 

i want to assign a password to an admin page but i have read so many tutorials i am confused

 

can you give me an example of what it could be like to protect a page using a flat file password system to store the users passwords..

 

sad but i am begging lol

A simple example (Not tested).

 

login.php

<?php

  $n = 'usernamehere';
  $p = 'passwordhere';

  session_start();
  if (isset($_SESSION['logged'])) {
    // already logged in.
    header("Location: index.php");
  }

  if (!isset($_POST['submit'])) {
    echo "<form method=\"post\">";
    echo "    <input type=\"text\" name=\"uname\">";
    echo "    <input type=\"password\" name=\"upass\">";
    echo "    <input type=\"submit\" name=\"submit\">";
    echo "</form>";
  } else {
    if ($_POST['uname'] == $p && $_POST['upass'] == $you) {
      $_SESSION['logged'] = true;
      header("Location: index.php");
    } else {
      // login failed.
      header("Location: {$_SERVER['PHP_SELF']}");
    }
  }

?>

 

Then, on index.php you would just need this at the top.

 

<?php

  session_start();
  if (!isset($_SESSION['logged'])) {
    // not loged in.
    header("Location: login.php");
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.