Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-09-2007, 11:30 AM
Toxitalk Toxitalk is offline
Registered User
 
Join Date: Nov 2007
Posts: 2
A slant on CMS tutorial

I require a cms style login for some work im doing (Its a sort of social networking site) so the tutorial about creating and validating a session user in the write a cms tutorial was great.

Im pretty sure I followed to the letter, my hosting is a vitural machine, running PHP Version 4.4.4-8+etch1 and mysql 5, safe php is off as well as register globals.

Now the issue I had with the php code is that the login script worked fine, but when it redirected to welcome.php something trips out, and it boots the user back to login.

Now for my requirement I just need the php to act as an intial guard dog to varify username and password.

My application will then query other tables to check what a user can do.

With this in mind this is now how the first part of my welcome.php looks

// if (!$theSentry->checkLogin(2) ){ header("Location: login.php"); die(); }
if (!$theSentry->checkLogin(2) ){}

if ($_SESSION['user']=="" OR $_SESSION['pass']=="")
{ header("Location: login.php"); die(); }

Are they any major flaws doing this, as im in a bit of a scrap?

Many thanks
Reply With Quote
  #2 (permalink)  
Old 06-14-2008, 08:51 AM
marzar00 marzar00 is offline
Registered User
 
Join Date: Jun 2008
Posts: 22
Hi,

I believe that the Sentry has already covered the check that they are logged in. Have a look in the Sentry.php file around the line 56-83. That code is checking if the user is logged in. That means that you can cut the following out of your page:
PHP Code:
if ($_SESSION['user']=="" OR $_SESSION['pass']=="")
{
header("Location: login.php"); die(); }
Really you should remove this:
PHP Code:
// if (!$theSentry->checkLogin(2) ){ header("Location: login.php"); die(); }
if (!$theSentry->checkLogin(2) ){}

if (
$_SESSION['user']=="" OR $_SESSION['pass']=="")
{
header("Location: login.php"); die(); }
And replace it with the default code:
PHP Code:
require_once('../includes/Sentry.php');
$theSentry = new Sentry();
if (!
$theSentry->checkLogin(2) ){ header("Location: login.php"); die(); }
Hope this helps,

Marzar

Edit: I just re-read your original post and realised what you are try to do.

The sentry code should redirect the user if they are logged in and are level 2 or 1 in this case. If you want more levels to be allowed access to this page then increase the checkLogin(__) number.

Last edited by marzar00; 06-14-2008 at 08:54 AM. Reason: Re-read original post
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 05:36 AM.





Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0