PDA

View Full Version : problem with sessions - logging in


Karkar
06-12-2007, 10:04 PM
I dont know if sessions is that problem or not really, but this is the deal:

I have 2 different logins - 1 for users and 1 for employees.

They both connect to 2 different tables on the db - one for users and one for employees obviously. For this reason ofcourse my security inludes are different for each.

The weird thing that is happening is this... when i launch the employee login, it works fine - i created this login first.

The user login does not work when I launch it - BUT - it does work if I login into it AFTER i log into the employee.

The elseif warnigs are workin fine... Here is the code for the user login and user area:


client_login.php

<?php
session_start();
require_once("connections/connection.php");
$userid = $_POST['userid'];
$password = $_POST['password'];
$submitted = $_POST['submitted'];

if ($userid && $password) {
/////////////////////
$query = sprintf("SELECT * FROM users where user_name='$userid' and user_password = '$password'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////
}
if ($rowAccount) {
$_SESSION['idclient'] = $rowAccount['field_id'];
header("location:client.php");
exit;
}elseif ($submitted){
$warning = "The information you have entered is incorrect";

}

?>


client page

<?php
session_start();
require_once("connections/connection.php");
include("includes/securityclient.php");
$idclient = $_SESSION['idclient'];
/////////////////////
$query = sprintf("SELECT * FROM users where field_id='$idclient' ");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////
///////////////////////////////////////////////
$query = sprintf("SELECT * FROM usr_upd");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
///////////////////////////////////////////////
?>

davidj
06-13-2007, 06:30 AM
so your client login is not working?

Karkar
06-13-2007, 06:46 AM
that's correct