English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi,

How do I chek if user is logged on and if He isent send to a Login Page?

Where do I out the code?

Thank you
Reiss

2007-10-28 01:39:18 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

Im using PHP, MySQL and PHPMYADMIN

2007-10-28 01:39:41 · update #1

3 answers

This is only a sample. You have to other stuffs like validation etc..

user_table
id
username
password


$username=$_POST['username']; //text name username
$password=$_POST['password']; //password name password

//start checking user exists in table

$query=mysql_query("SELECT * FROM user_table WHERE username='$usernamt' AND password='$password'");
if(mysql_num_rows($query) > 0)
{
$fetch_det=mysql_fetch_array($query);
$id=$fetch_det['id'];
session_start();
$_SESSION['id']=$id;

header("Location: user_page.php");

}
else
{
echo 'Invalid login';
}
//

in user_page.php check for the session if it is not set or it is empty redirect to login page

2007-10-28 02:15:49 · answer #1 · answered by shiva0101 m 1 · 1 0

The idea is too simple:
When you log on you send a request to MySqol to find out if the username and password are available
Select from table …….. where username = $.. and pw=$….
In this case we have two possibilities
1- the password and user name are available ( reroute the user to particular page )
2- the password and username are not available ( reroute the user to error page)

2007-10-28 08:51:19 · answer #2 · answered by Mag 7 · 1 0

Depends on how they've logged on. Normally you can run tho command "who" to see who is on. If you've written or are using a non-linux operating system logon method, then you'll need to check the manual for that method or application.

2007-10-28 08:42:07 · answer #3 · answered by Linux OS 7 · 1 0

fedest.com, questions and answers