PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 11th, 2003, 09:37 PM
PHPme's Avatar
PHPme PHPme is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 319 PHPme User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 8 m 32 sec
Reputation Power: 6
Malfunctioning Login/Logout

These scripts do not seem to work properly. Sometimes on entering the correct user/password, it simply keeps defaulting back to the login page. Sonetimes if i click the login button with no info in the user/pswd, it gives me an existing session on a page. And when i try to move onto another page (each location has 2 pages) it defaults back to the login page. The only time it seems to work ok is when i access all pages directly, and if they give me access i specifically logout of them one by one. I guess i need to destroy the session at some point in the Logout script, how would i do that without logging out any other user that may have also signed in?
Or if anyone has any better suggestion of doing this login/logout, please let me know. Thanks
Login.php
PHP Code:
<?php
//verify if the user/pw iscorrect
session_start();//start a session

if (($_POST['f_user'] == "Ams") && ($_POST['f_pass'] == "111") && ($_POST['City'] == "AMS"))
{
 
$_SESSION['AMS'] = "AMS";
 
//session_name("AMS")
 
header("Location: http://www....com/AMS/Ams/UpdateCurrencyAms.php");
}
elseif ((isset(
$_SESSION['AMS'])) &&  ($_SESSION['AMS'] == "AMS"))
{
 
header("Location: http://www....com/AMS/Ams/UpdateCurrencyAms.php");
}
elseif ((
$_POST['f_user'] == "Ant") && ($_POST['f_pass'] == "222") && ($_POST['City'] == "ANT"))
{
 
$_SESSION['ANT'] = "ANT";
 
header("Location: http://www....com/ANT/Ant/UpdateCurrencyAnt.php");
}
elseif ((isset(
$_SESSION['ANT'])) &&  ($_SESSION['ANT'] == "ANT"))
{
 
header("Location: http://www.....com/ANT/Ant/UpdateCurrencyAnt.php");
}
elseif ((
$_POST['f_user'] == "Prg") && ($_POST['f_pass'] == "333") && ($_POST['City'] == "PRG"))
{
 
$_SESSION['PRG'] = "PRG";
 
header("Location: http://www.....com/PRG/Prg/UpdateCurrencyPrg.php");
}
elseif ((isset(
$_SESSION['PRG'])) &&  ($_SESSION['PRG'] == "PRG"))
{
 
header("Location: http://www....com/PRG/Prg/UpdateCurrencyPrg.php");
}
elseif ((!isset(
$_POST['f_user'])) || (!isset($_POST['f_pass'])) || (!isset($_POST['City'])))
{
     
header("Location: http://www....com/Login.htm");
}
else
{
      
header("Location: http://www..../Login.htm");
}
?>

Logout.php
PHP Code:
<?php
session_start
();
if (
$_GET['City'] == "AMS")
{
    if ((isset(
$_SESSION['AMS'])) && ($_SESSION['AMS'] == "AMS"))
    {
    
// remove the 'AMS' session var
    
unset($_SESSION['AMS']);
    
header ("Location: http://www.....com");
    }
    else
    {    
    
header ("Location: http://www....com");
    }

}

elseif (
$_GET['City'] == "ANT")
{
    if ((isset(
$_SESSION['ANT'])) && ($_SESSION['ANT'] == "ANT"))
    {
    
// remove the 'AMS' session var
    
unset($_SESSION['ANT']);
    
header ("Location: http://www.....com");
 }
 else
    {    
    
header ("Location: http://www....com");
    }
}
elseif (
$_GET['City'] == "PRG")
{
    if ((isset(
$_SESSION['PRG'])) && ($_SESSION['PRG'] == "PRG"))
    {
    
// remove the 'PRG' session var
    
unset($_SESSION['PRG']);
    
header ("Location: http://www.....com");
 }
 else
    {    
    
header ("Location: http://www....com");
    }
}
?>

Here is the check on each page to check for an existing session
Ams.php
PHP Code:
<?php
session_start
();
if ((!isset(
$_SESSION['AMS'])) || ($_SESSION['AMS'] != "AMS"))
{
    
header("Location:http://www......Login.htm");
}
else
{
?>
<html>
<head>
...rest of page...
<a href="../../Logout.php?City=AMS">LogOut</a>
.......
<?php 
}//end else
?>

Last edited by PHPme : October 11th, 2003 at 09:44 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Malfunctioning Login/Logout


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT