FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

i need a single user login system

 


jayzee
hi guys i m in search of a single user login system in php without mysql..
hexkid
jayzee wrote:
hi guys i m in search of a single user login system in php without mysql..


index.php
Code:
<?php
session_start();
$_SESSION['logged'] = false;
if (isset($_POST)) {
  if (($_POST['username'] == '') && ($_POST['password'] == '')) {
    $_SESSION['logged'] = true;
    echo 'You are now logged in.<br>';
    exit('Feel free to <a href="browse.php">browse the site</a>.');
  } else {
    echo 'Invalid login.<br>';
    exit('<a href="' . $_SERVER['PHP_SELF'] . '">Try again</a>.');
  }
} else {
?>
<form action="" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<inputt ype="submit" value="Login">
</form>
<?php
}
?>


browse.php (and all other pages)
Code:
<?php
session_start();
if (!isset($_SESSION['logged']) || $_SESSION['logged'] !== true) {
  exit('You need to <a href="index.php">log in</a>.');
}

### insert page contents here

?>
jayzee
hexkid wrote:
jayzee wrote:
hi guys i m in search of a single user login system in php without mysql..


index.php
Code:
<?php
session_start();
$_SESSION['logged'] = false;
if (isset($_POST)) {
  if (($_POST['username'] == '') && ($_POST['password'] == '')) {
    $_SESSION['logged'] = true;
    echo 'You are now logged in.<br>';
    exit('Feel free to <a href="browse.php">browse the site</a>.');
  } else {
    echo 'Invalid login.<br>';
    exit('<a href="' . $_SERVER['PHP_SELF'] . '">Try again</a>.');
  }
} else {
?>
<form action="" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<inputt ype="submit" value="Login">
</form>
<?php
}
?>


browse.php (and all other pages)
Code:
<?php
session_start();
if (!isset($_SESSION['logged']) || $_SESSION['logged'] !== true) {
  exit('You need to <a href="index.php">log in</a>.');
}

### insert page contents here

?>


thanx alot.....
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.