Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Newbie question...login system

 
   Database Forums (Home) -> PHP RSS
Next:  Primary Key Question  
Author Message
stacey

External


Since: Aug 31, 2007
Posts: 2



(Msg. 1) Posted: Fri Aug 31, 2007 8:23 am
Post subject: Newbie question...login system
Archived from groups: comp>lang>php (more info?)

Hi all,

I am trying to create a login system for my site. I've got everything
working properly so far, but I would like to make it a bit cleaner.

Currently, on each page that requires the user to be logged in, I am
checking the session first and redirecting them to the login page if
they are not logged in...else, I display the page contents.

Is there a way that I can, somehow, create some sort of function that
will check a 'config' file to see if the page requires the user to be
logged in? For instance, I'd like to be able to put one call in my
header file that checks to see if the current url requires a login.
What I'm trying to avoid, is having to put the login check in each
specific page.

Also, I would like to save the referring url so I can redirect them
back to where they were trying to go in the first place.

Hope this makes sense...

Thanks in advance for any suggestions,
Stacey

 >> Stay informed about: Newbie question...login system 
Back to top
Login to vote
stacey

External


Since: Aug 31, 2007
Posts: 2



(Msg. 2) Posted: Fri Aug 31, 2007 10:08 am
Post subject: Re: Newbie question...login system [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thank you...that was exactly what I was looking for!

 >> Stay informed about: Newbie question...login system 
Back to top
Login to vote
ELINTPimp

External


Since: Jun 30, 2007
Posts: 21



(Msg. 3) Posted: Fri Aug 31, 2007 2:00 pm
Post subject: Re: Newbie question...login system [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 31, 11:23 am, stacey wrote:
> Hi all,
>
> I am trying to create a login system for my site. I've got everything
> working properly so far, but I would like to make it a bit cleaner.
>
> Currently, on each page that requires the user to be logged in, I am
> checking the session first and redirecting them to the login page if
> they are not logged in...else, I display the page contents.
>
> Is there a way that I can, somehow, create some sort of function that
> will check a 'config' file to see if the page requires the user to be
> logged in? For instance, I'd like to be able to put one call in my
> header file that checks to see if the current url requires a login.
> What I'm trying to avoid, is having to put the login check in each
> specific page.
>
> Also, I would like to save the referring url so I can redirect them
> back to where they were trying to go in the first place.
>
> Hope this makes sense...
>
> Thanks in advance for any suggestions,
> Stacey

Stacey,

I assume your problem is that you have a site template, or something
of the sort, that precludes you from either including your check at
the top or not. Something like I go to page1.php and at the top of
page1.php, you have <?php require_once "head.php"; ?>, where all your
autentication/authorization goes on?

if this is true...why don't you set a variable before the include.

<?php
//page1.php

$requires_auth = true;

.....
?>

<?php
//head.php

if ($requires_auth) {
 >> Stay informed about: Newbie question...login system 
Back to top
Login to vote
ELINTPimp

External


Since: Jun 30, 2007
Posts: 21



(Msg. 4) Posted: Fri Aug 31, 2007 2:00 pm
Post subject: Re: Newbie question...login system [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 31, 12:17 pm, ELINTPimp wrote:
> On Aug 31, 11:23 am, stacey wrote:
>
>
>
> > Hi all,
>
> > I am trying to create a login system for my site. I've got everything
> > working properly so far, but I would like to make it a bit cleaner.
>
> > Currently, on each page that requires the user to be logged in, I am
> > checking the session first and redirecting them to the login page if
> > they are not logged in...else, I display the page contents.
>
> > Is there a way that I can, somehow, create some sort of function that
> > will check a 'config' file to see if the page requires the user to be
> > logged in? For instance, I'd like to be able to put one call in my
> > header file that checks to see if the current url requires a login.
> > What I'm trying to avoid, is having to put the login check in each
> > specific page.
>
> > Also, I would like to save the referring url so I can redirect them
> > back to where they were trying to go in the first place.
>
> > Hope this makes sense...
>
> > Thanks in advance for any suggestions,
> > Stacey
>
> Stacey,
>
> I assume your problem is that you have a site template, or something
> of the sort, that precludes you from either including your check at
> the top or not. Something like I go to page1.php and at the top of
> page1.php, you have <?php require_once "head.php"; ?>, where all your
> autentication/authorization goes on?
>
> if this is true...why don't you set a variable before the include.

blah, accidentally submitted

<?php
//page1.php

$requires_auth = true;

....
?>



<?php
//head.php

if ($requires_auth) {
//do autehntication
}
?>


If your doing something else, let us know so we can find a solution to
your specific problem
 >> Stay informed about: Newbie question...login system 
Back to top
Login to vote
ELINTPimp

External


Since: Jun 30, 2007
Posts: 21



(Msg. 5) Posted: Fri Aug 31, 2007 4:00 pm
Post subject: Re: Newbie question...login system [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 31, 1:08 pm, stacey wrote:
> Thank you...that was exactly what I was looking for!

no problem
 >> Stay informed about: Newbie question...login system 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
secure login system - Hi group, I need a login system for some 'private' pages. Users should be pulled from a mysql DB. Now, i've read a lot on login systems, and somehow there's _always_ the discussion with sessions (hijacking), dynamic IPs/Proxies. One hand sessions on..

Question from PHP newbie -

A simple newbie question - Hello. I started writing PHP today. I added the following code at a php page. <?php if($_SESSION["dbpwd"]=="") { print("EMPTY!"); $_SESSION["dbpwd"]="TEST"; print(" SET TO ".$_SESSION...

Newbie question on being "crippled" - I am just playing with PHP at the moment and all my code is just run on a local apache non-internet server. Most of my PHP use at the moment is just reading about it but it looks like fun and an alternate to Perl for CGI stuff. But, I keep coming acros...

Newbie Question: How to prevent sending blank form Script .. - I have an html form which goes to this script. It works, but I want to prevent the form input being sent unless some of the input fields have data. The reason is so that people don't submit blank forms by accident (which triggers a counter, not shown....
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]