[FX.php List] Passwords
andy at fmpug.com
andy at fmpug.com
Tue Dec 6 09:35:46 MST 2005
Peter -
Look into Sessions with PHP http://us3.php.net/manual-lookup.php?pattern=sessions. When you use sessions you need to ensure on each page you start with a session_start tag.
session_start();
You can also set your php.ini to auto start sessions for you
When your users log-in you can set a session variable to their access level;
$_SESSION['accesslevel'] = 'x'
where x is either a, b or c
Then when you go to those pages you can check the session variable value. If access is not allowed you can use a header redirect to take them out of the page.
<?php
session_start();
if ($_SESSION[accesslevel] != 'x')) {
//Set x to the relevant access level
//Access not allowed for this page
$thankyouurl = "index.php";
header( "Location: $thankyouurl" );
exit;
}
?>
I find the easiest way to ensure the session is started is to place that call in an included php page that is on every single page.
Anyhow, hope this helps you out.
Regards
Andy Gaunt
http://www.fmpug.com
>
>My Setup: Mac OS 10.4.3 Server - Apache - FMP 8 database served by
>FMSA7 and FX.php.
>
>I need a way password protect access to various links (pages), so
>that only users with the correct username and password can access.
>Examples: User A can get to pages A, B, & C.
>User B can get to page B only.
>User C can get to pages A & C, and so on.
>
>As I'm still learning the in and outs of FX.php and PHP, would one of
>the experts here, please send me a code snippet that would give me an
>example of how to do this.
>
>Thanks,
>
>Peter Bates
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list