Using PHP 404pl1 / 3.23.22-beta / sessions is enabled and working.
Why the *#%&" doesn't this piece of code work?
The comments are in swedish, but since i think that the program is
easily understood anyway, i didn't translate them.
This is supposed to be a login screen where i save the page the user
came from.
So when the user has logged in - he/she is supposed to be able to return
to the page he left off from by clicking on the "G� tillbaka" link.
Imagine that this code gets called from a page called start.php
The first time the referer to start.php gets stuffed in the global
session variable $auth[referens].
Since the login page is called every time the user makes a try to login
i also set a 'flag' called refhold to avoid $auth[referens] to be
altered.
This works as expected until i hit the login button and execute the
POST.
Then, somehow the $auth[referens] get changed (even thou the flag is set
and thus don't execute the "$auth[referens]
=$HTTP_SERVER_VARS['HTTP_REFERER'];" line.
Anyone got a clue?
=========================================================
code
=========================================================
<?php
include ("../database.inc");
session_start();
session_register("auth");
// Memorera referens
if ($auth[refhold] == 0 ){
$auth[referens] =$HTTP_SERVER_VARS['HTTP_REFERER'];
echo "refhold s�tts<BR>";
$auth[refhold] = 1;
} else {
echo "refhold �r satt<BR>";
}
// Kontrollera inloggning
if ($HTTP_POST_VARS['submit'] == "LOGGA IN"){
// Tag hand om inloggningsuppgifterna
$login = $HTTP_POST_VARS['login'];
$pwd = $HTTP_POST_VARS['pwd'];
// Koppla upp mot databasen
mysql_connect($DBserver, $DBlogin, $DBpwd);
mysql_select_db($DBnamn);
$result = mysql_query("SELECT anvandare.login, anvandare.pwd,
anvandare.id, anvandare.namn, anvandare.efternamn, anvandare.sign FROM
anvandare");
if ($row = mysql_fetch_array($result)) {
do {
if (( $row[0] == $login) && (($row[1] == $pwd) OR ($row[1] ==
NULL) )){
$auth = array ("login" => $login,
"id" => $row[2],
"namn" => $row[3],
"efternamn" => $row[4],
"sign" => $row[5],
"inloggad" => 1);
}
} while($row = mysql_fetch_array($result));
} else {
unset($auth[inloggad]);
}
}
if (! isset($auth[inloggad])) {
echo "Ej inloggad";
} else {
echo "Inloggad";
}
?>
<HTML>
<HEAD><TITLE>Logga in</TITLE></HEAD>
<BODY>
<FORM ACTION="<?PHP echo $PHP_SELF; ?>" METHOD=POST>
<table border="0" width="25%">
<TR>
<TD>Namn:</TD><TD><INPUT TYPE="text" NAME="login"></TD>
</TR>
<TR>
<TD>L�senord:</TD><TD><INPUT TYPE="password" NAME="pwd"></TD>
</TR>
<TR>
<TD colspan="2" align="center"><INPUT TYPE="submit" NAME="submit"
VALUE="LOGGA IN"></TD>
</TR>
</table>
</FORM>
<a href="<?PHP echo $PHP_SELF; ?>">hoppa till denna sida igen</a>
<a href="<?PHP echo "$auth[referens]";?>">G� tillbaka</a>
<a href="../Login/Logout.php">Logga ut</a>
</BODY>
</HTML>
=========================================================
--
Michel Laine
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]