FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Login System help





diddle
I decided to install a login system for my website.
its created by: http://www.maaking.com/
The database works and all, but once you log in to the thing
it brings you to a index.php page, and it just says you last logged in at w/e w/e.
I wanted to know if there was a code to redirect it to my homepage once the member has logged in and a code the makes it so if a unauthorized person tries to enter my website through a different pathway or something, they are redirected to the login page. And if they access my site normally say, by the normal url or other pages (www.something.frih.net or www.something/frih.net/downloads) they will be directed to the login page
Heres my link to the login page:
http://diddlemcfiddle.frih.net/login/users.php
Hopefully someone can help me with this.
My website is underconstruction right now, so dont ask me why i need a
user login system.
raver
taken from the manual...

Code:

<?php
/* Redirect to a different page in the current directory that was requested */
$host  = $_SERVER['HTTP_HOST'];
$uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>


as for the checking of they are logged in, you can simply set a session variable when they do log on, and then just check if that session var is set.. for example..
Code:

if (they are logged in) {
$_SESSION['logged_in'] = true;
}

and then on every page...
if ($_SESSION['logged_in'] != true) {
$host  = $_SERVER['HTTP_HOST'];
$uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
diddle
does this also work in html? like i want to have a little bar in a corner or something that shows they are logged in and there is an option to logout.
Right now ive made the login able to redirect to the homepage, but its not protected. Can i like specify the database with the usernames that are in it and that the usernames in it are able to access the protected page? Im a bit confused.
raver
the ideea is simple... you have two types of pages, some which you want to protect, and some which should be available to everyone.
When someone registers, their data is inputed in the database...
When the log in, the script checks to see if the user and password supplied by the user are corect, and set a session variable like i've shown you above. And then on every page which should be password protected you check if the session variable is set. If not, redifrect him to the login.php page or whatever.
also, all pages must be .php, not .html
Related topics
html login system
Simple login system
news system with login for more than 1 user.
Developing a Login System with PHP and MySQL
i need a single user login system
PhP/mySQL problem need help!
Website login- How?
Login System Tutorial Part 1 Creating Registration
.: User login systems for your site :. CHEAP AND EASY!
Frih$ on offer for PHP Login System
Could someone create a really simple login system???
Login system with uploading features!
PHP and MySQL login...Help
Creating safe persistent login system
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.