Jump to content

Login Matrix


e1seix

Recommended Posts

OK, I have a mate who has kindly written up the following for me:

 

On your login page just add:

If(//check login){
                $_SESSION[‘id’] = $dbRow[‘userId’]; // ASSIGN AN ID / ANYTHING TO ‘id’
//rest of your code...
}

On all other pages in the CMS, include a file at the top:
<?php
include(‘allowed.php’);

//rest of code...
?>

Allowed.php

<?php
if(!isset($_SESSION[‘id’])) header(‘Location:./index.php’);
// IF THEY AREN’T LOGGED IN TAKE THEM TO THE LOGIN SCREEN
?>

 

I have applied it to my site, but I don't appear to be able to get it working.

 

The login page is one "/admin/index.php" and the redirect for having passed security is "/admin/home/index.php"

 

Login page:

$query = 'SELECT * FROM admin';
$results = mysql_query( $query ) or die(mysql_error());
while($row = mysql_fetch_array( $results )) {

  $username = $row["username"];
  $password = $row["password"]; }

    if ( $_POST["username"] == $username && $_POST["password"] == $password ) {

      $_SESSION["id"] = $username;
      header('Location: /admin/home/?db=outlet&tbl=imported&search=2010-03-20&ob=new+DESC&limit'); }

    else { ?>

      <form action="/admin/home/?db=outlet&tbl=imported&search=2010-03-20&ob=new+DESC&limit=" method="post" name="login">
        <input type="text" name="username" />
        <input type="password" name="password" />
        <input type="submit" value="Login" />
      </form><? } ?>

 

Allowed page:

<?

if(!isset($_SESSION["id"])) {

header('Location: /admin/'); }

?>

 

It keeps just diverting back to the original login page, no matter what I do.

 

All help appreciated.

Link to comment
https://forums.phpfreaks.com/topic/195912-login-matrix/
Share on other sites

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.