It is usually wise to search through old posts before posting a question
that's been answered before all over again.  Here is a previous answer given
by myself to someone who asked the same question as you:

The easiest way is to use cookies.
=========CODE============
<?php
require 'auth_functions.php';
if (authenticateUser($form_username, $form_password)){
   setcookie("cookie_passwd",$form_password);
   setcookie("cookie_user",$form_username);
   header("Location:http://$SERVER/index2.php";);
   exit();
} else {
header("Location:http://$SERVER/error.html";);
}
?>

This code takes in input from a form as simple as this:
<form name="form1" method="post" action="index.php">
  Login: <input type="text" name="form_username"><br>
  Password:
  <input type="password" name="form_password"> <br>
  <input type="submit" name="Submit" value="Login">
</form>
Checks it against the database values using the function 'authenticateUser',
returns TRUE or FALSE.
If true, sends the user onto the correct page, if false, sends them to some
error page.

Now, in each other file, you'll need to check the cookies.  The values for
the cookies are sent automatically by the user's browser.  In this
particular examples, the cookie variables are named '$cookie_user' and
'$cookie_passwd'.  You can see in the example how those are set.

You will check the cookies using the exact same 'authenticateUser' function.
Except in these files, you will use the cookie values as the parameters to
the function instead of the form values.  I.e.
authenticateUser($cookie_user,$cookie_passwd);

Hope this helps.

Best regards,

Jeremy Reed

"Jack" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dear all
> I want to provide a login page to the user when they want to visit my
> website, i got no idea what should i used.
> First i have a login.php page which got two input box, one for username
and
> one for password.
> Then i have a login table with mysql database which contain the valid user
> and password.
> And i have a index.htm which let the user browse my website.This index.htm
> is consist of three frame, top, left and main. Each frame contain
different
> page(.php).
>
> Task :
> User will login first through login.php, then the username and password
> provided by user will need to match the table called login.
> Once the username and password is correct, the username will be hold in a
> place for the further use inside the website(eg: when user want to see the
> leave history records, it will only show it's own record by select the
query
> using the username section).
> then user will direct into index.htm.
>
> Could someone pls give me a idea how i should make this system work??
>
> Thx
> Jack
> [EMAIL PROTECTED]
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to