HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Authenication on each page
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
ainoy31



Joined: 25 May 2007
Posts: 5

PostPosted: Mon Jun 04, 2007 9:19 am     Authenication on each page Reply with quote

I need to authenicate username and password on each page so people can not just access them. I only have one admin login in the database. I have an admin login page for username and password to enter. Once that is entered, these two info gets posted on a validation page where is checks against the database. If everything is correct, then I redirect them to another page. If the username and password is incorrect, then I redirect to the admin login page.

What would be the best way to authenicate user at each page?

thx.

AM
saboi



Joined: 22 Mar 2007
Posts: 9

PostPosted: Thu Oct 18, 2007 12:57 am     Reply with quote

Hi, you can use sessions or cookies for that.

Create a global session when the user logs on.

$pass=$_['pass'];
$name=$_['name'];

if($pass=="password" $$ $name=="name")

{$_SESSION["name"]=$name;header("Location:allow.php");

}

else{ echo"Incorrect loggin details!";}

On each page that you would like to validate include something like below


<?
session_start();

if((isset($_SESSION["name"]))

{echo"You are not signed in!;}

?>

When someone goes directly to that site and the session is not set(that only done at loggin), they will get the message telling them they are not logged in.

Hope that helps.
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial