|
-
Feb 15th, 2010, 12:03 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Wierd Must Login Twice Error
Hi,
I'm very new to PHP to excuse my code...
On my login form, its making me have to login twice, second time is always sucessful, never the first time. As far as I can tell my code is ok, but again, I'm new to PHP. Can anyone shed some light on this for me please Thanks.
PHP Code:
if ($log == "login")
{
if ($_SESSION['_TO'] != 'staff')
{
$_SESSION['_FROM']='staff';
header('Location: ../config.php');
}
elseif ($_SESSION['_TO'] == 'staff')
{
$conn=odbc_connect($_SESSION['base_source'],$_SESSION['db_user'],$_SESSION['db_pass']);
if (!$conn)
{
exit ($_SESSION['userrecid']="Connection Failed!");
}
$_SESSION['_MyUsername']=$_POST['username'];
$_SESSION['_MyPassword']=$_POST['password'];
$sql="SELECT Users.\"NAME\", Users.\"PASSWORD\", Logon.\"STATUS\" FROM Users LEFT OUTER JOIN Logon ON Logon.\"USER\" = Users.\"NAME\" WHERE \"NAME\"='".$_SESSION['_MyUsername']."' and \"PASSWORD\"='".$_SESSION['_MyPassword']."'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit ($_SESSION['userrecid']="Error in SQL!");
}
$count=odbc_num_rows($rs);
$status=odbc_result($rs,"STATUS");
if($count==1)
{
if($status==1)
{
$_SESSION['userrecid']="This user is already logged into inspHire!";
header("location: ./ ");
}
elseif($status==0)
{
$sql="UPDATE LOGON SET \"STATUS\"=1 WHERE \"USER\"='".$_SESSION['_MyUsername']."'";
$rs=odbc_exec($conn,$sql);
$_SESSION['_EXEC']=1;
header("location: ./staff-gateway.php");
}
}
else
{
$_SESSION['userrecid']="An Error Has Occured! $status";
header("location: ./ ");
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|