Login/logout problems

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Gubbins
New php-forum User
New php-forum User
Posts: 3
Joined: Tue Feb 18, 2003 9:46 am

Login/logout problems

Postby Gubbins » Tue Feb 18, 2003 10:30 am

I am having a login problem which I can't solve. I'm fairly new to PHP so am probably overlooking something simple. If someone could point out the source of my stupidity I'd be grateful.

I am able to login once to my site with no problems. However, if I logout and try to log back in I get errors saying that the indexes 'user' and 'pass' are undefined. The only way to login a second time is to re-open the browser and try again.

The code is given below:

login:

<?
include("connect.php");

if(isset($type) && ($type == 'login'))
{
$user = $_POST['user'];
$pass = $_POST['pass'];

if(($user != '') && ($pass != ''))
{
$qry = "select decode(pass,'notrealstring'), userid from users where user = '$user'";
$result = mysql_query($qry);
$row = mysql_fetch_array($result);
$correct = $row["decode(pass,'notrealstring')"];

if($pass == $correct)
{
//redirect to main site
}
else
{
//back to login, retry
}
}
else
{
//back to login, retry
}
}
?>

logout:

<?
include("connect.php");
session_unset();
session_destroy();
?>

I suspect that i am not logging out correctly but any suggestions are appreciated.

philipo
New php-forum User
New php-forum User
Posts: 2
Joined: Wed Nov 06, 2002 4:02 am
Contact:

Postby philipo » Tue Feb 18, 2003 10:44 am

Do you use sessions?

you need a variable to use session_unset();

like... $username...

Code: Select all

session_unset($username);
[/code]

Gubbins
New php-forum User
New php-forum User
Posts: 3
Joined: Tue Feb 18, 2003 9:46 am

Postby Gubbins » Tue Feb 18, 2003 11:30 am

Thanks for your help Philipo.
Yes, I am using sessions.
I made the corrections you mentioned to unset all the session vars but my problem persists.

The login form sends the username and password using the post method when the submit button is clicked. However, on clicking the button, the action seems to be correct (ie correct page opens) but the username and password don't seem to be passed to the login script.
This problem only occurs if I try to login after logging out and not closing the browser.

Any further pointers would be appreciated.

Gubbins
New php-forum User
New php-forum User
Posts: 3
Joined: Tue Feb 18, 2003 9:46 am

Postby Gubbins » Tue Mar 11, 2003 1:51 am

Anyone?? This must have happened to someone before.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron