e1seix Posted March 20, 2010 Share Posted March 20, 2010 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 More sharing options...
Ruzzas Posted March 20, 2010 Share Posted March 20, 2010 Make a page called login.php then and make it redirect there so it doesnt look so complicated. And i dont understand the problem you are having can you explain more clearly please, Thanks Link to comment https://forums.phpfreaks.com/topic/195912-login-matrix/#findComment-1029090 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.