Hi all,
Still unable to get this to work.
I currently have a database that has a table named 'members'. This table has a few fields, they are login_name, password and admin.
Here is the problem...when the user goes to the login page (members.htm) and submits the form the validate.php script kicks in (see script below).
The clients and admin staffs username and password are shared within the database...however the admin staff are assigned the value 'yes' in the admin field of the database.
What i want to be able to do is depending on who logs in (client or admin staff) which page they goto. At the moment if the admin user logs in they goto the correct page (membership.php) but if a client logs in what do i need to add to the script inorder for it to goto the index.php page?
Cheers,
micmac
validate.php
<?
session_start();
if ($userid && $password)
{
// if the user has just tried to log in
$db_conn = mysql_connect('localhost', '', '');
mysql_select_db("psp", $db_conn);
$query = "SELECT * FROM members WHERE login_name='$userid' AND password='$password' AND admin='yes'";
$result = mysql_query($query, $db_conn);
if (mysql_num_rows($result) >0 )
{
// if they are in the database register the user id
$valid_user = $userid;
session_register("valid_user");
}
}
if (session_is_registered("valid_user"))
{
// logged in successfully to membership area
header ("Location: membership.php ");
}
else
{
if (isset($userid))
{
// if they've tried and failed to log in
header ("Location: warning.php ");
}
else
{
// they have not tried to log in yet or have logged out
header ("Location: warning.php ");
}
}
?>