Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > Pasword Protecting several pages
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 26th April 05:02
rme
External User
 
Posts: 1
Default Pasword Protecting several pages


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
  Reply With Quote


  sponsored links


2 26th April 05:02
micah
External User
 
Posts: 1
Default Pasword Protecting several pages


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
  Reply With Quote
3 26th April 05:02
rme
External User
 
Posts: 1
Default Pasword Protecting several pages


Thank you Micah,

Could you give me some code on that?

Ref
  Reply With Quote
4 26th April 08:48
micah
External User
 
Posts: 1
Default Pasword Protecting several pages


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
  Reply With Quote
5 26th April 08:49
tedd.sperling
External User
 
Posts: 1
Default Pasword Protecting several pages


Ref:

It you will look, this is what I prepared for you:

http://webbytedd.com/b1/simple-session/

Everything you need is there.

Hope this helps,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666