Re: Pasword Protecting several pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



checkLogin.php

<?php

session_start();
if ($_SESSION['login'] != true)
{
    header("Location: login.php");
    exit();
}

?>

info.php

<?php

include_once('checkLogin.php');

...Code goes here...

?>

login.php

<?php

session_start();

if ($_POST['Username'] == *Check Credentials Here*)
{
    $_SESSION['login'] = true;
    header("Location: info.php");
    exit();
}

//Output Form Here

?>

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



R.C. wrote:
> Thank you Micah,
>
> Could you give me some code on that?
>
> Ref
>
> "Micah Gersten" <micah@xxxxxxxxxxx> wrote in message
> news:4883F8C5.9070609@xxxxxxxxxxxxxx
>   
>> Set a session variable after the login has been confirmed and check for
>> it at the beginning of every page.  If it's not set, then redirect to
>>     
> login.
>   
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>>
>>
>> R.C. wrote:
>>     
>>> I'm still trying to get this scenario worked out and don't seem to be
>>>       
> able
>   
>>> to get it done.
>>>
>>> Here's what I'm trying to do:
>>> User logs into a login page and inputs email address and password.  User
>>> accessess password protected page, which contains a few links.  User
>>>       
> clicks
>   
>>> on one of the links, opens page, looks at content and then clicks back
>>>       
> to
>   
>>> main page.
>>>
>>> User is now asked to input password again.... what do I have to do to
>>>       
> make
>   
>>> sure all related links/pages on the main.php page are accessible with
>>>       
> that
>   
>>> same password the user input the first time?  Also.. how can I password
>>> protect ALL the linked pages on the main.php site with the same password
>>>       
> but
>   
>>> user only has to log in once!!
>>>
>>> No database, but just sessions?  I looked at those and also Tedd was
>>>       
> kind
>   
>>> enough to send something but for some reason I can't get it to go.
>>>
>>> Can someone forward some good instructions on how to accomplish this
>>>       
> task?
>   
>>> I would greatly appreciate it. Still learning this program as you can
>>>       
> tell.
>   
>>> Best
>>> Ref
>>>
>>>
>>>
>>>
>>>
>>>
>>>       
>
>
>
>   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux