Sesssion prob
Ja, den vil ikke gemme session, den kommer ikke med nogen fejl, så session understøttes, og filen hedder da også .php4... jeg bruger nogenlunde samme script et andet sted, og der virker det fint...<?
if($mode == \'newuserok\') {
header(\"location:login.php4\");
$pass = md5($pass1);
$link = mysql_connect(\"host\",\"user\",\"pass\");
mysql_select_db(\"acra\",$link);
mysql_query(\"INSERT INTO users (id,navn,alder,pass,adresse,city,postnr,profil,username) values (\'\',\'$navn\',\'$alder\',\'$pass\',\'$adresse\',\'$city\',\'$postnr\',\'$profil\',\'$user\')\");
} elseif($mode == \'login\' && $action == \'ok\') {
session_start();
session_register(\"user\");
session_register(\"userid\");
print(\'<meta http-equiv=\"refresh\" content=\"1;URL=login.php4\">\');
} elseif($mode == \'login\' && $action == \'check\') {
$l = mysql_connect(\"host\",\"user\",\"pass\");
mysql_select_db(\"acra\",$l);
$q = mysql_query(\"SELECT * FROM users WHERE username = \'$user\'\");
$r = mysql_fetch_array($q);
if ($r[pass] == md5($pass)) {
$userid = $r[id];
session_start();
session_register(\"user\");
session_register(\"userid\");
header(\"location:?mode=login&action=ok\");
}
}
?>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<HTML>
<HEAD>
<LINK REL=\"stylesheet\" HREF=\"comstyles.css\" TYPE=\"text/css\">
</HEAD>
<BODY>
<?
if($mode == \'login\' && $action == \'check\') {
if ($r[pass] != $pass) {
?>
Your username or password is worng. Try again.<br>
<FORM METHOD=POST ACTION=\"?mode=login&action=check\">
<INPUT TYPE=\"text\" NAME=\"user\" style=\"width:200px;\"><br>
<INPUT TYPE=\"password\" name=\"pass\" style=\"width:200px;\"><br>
<INPUT TYPE=\"submit\" value=\"Login\" style=\"width:200px;\">
</FORM>
<?
}
}
if(!$mode) {
print(\"<center>\");
if($user) {
print(\"<div class=\\\"head\\\">You are now logged in as $user. Use the menu on the top to navigate around the Community of TechnoToilet.</div>\");
} else {
print(\"<div class=\\\"head\\\">You are not logged in.</div><div class=\\\"main\\\"><a href=\\\"?mode=login\\\">Click here to login.</a><br><a href=\\\"?mode=newuser\\\">New user? Click here.</a></div>\");
}
print(\"</center>\");
} elseif($mode == \'login\' && !$action) {
?>
<div class=\"head\">Login</div><div class=\"main\">
<FORM METHOD=POST ACTION=\"?mode=login&action=check\">
<INPUT TYPE=\"text\" NAME=\"user\" style=\"width:200px;\"><br>
<INPUT TYPE=\"password\" name=\"pass\" style=\"width:200px;\"><br>
<INPUT TYPE=\"submit\" value=\"Login\" style=\"width:200px;\">
</div>
</FORM>
<?
} elseif ($mode == \'newuser\') {
?>
<TABLE cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"text-align:left;\"><TR><TD>
<form action=\"?mode=checknewuser\" method=\"post\">
<font class=\"text\">
Your name *<br><INPUT TYPE=\"text\" NAME=\"navn\" size=\"27\"><br>
Choose a username *<br><INPUT TYPE=\"text\" NAME=\"user\" size=\"27\"><br>
Password *<br><INPUT TYPE=\"password\" NAME=\"pass1\" size=\"27\"><br>
Password again *<br><INPUT TYPE=\"password\" NAME=\"pass2\" size=\"27\"><p>
Adress<br><INPUT TYPE=\"text\" NAME=\"adresse\" size=\"27\"><br>
Postal code and city<br><INPUT TYPE=\"text\" NAME=\"postnr\" size=\"4\" maxlength=\"4\">
<INPUT TYPE=\"text\" NAME=\"city\" size=\"25\" class=\"text\"><br>
Age *<br><INPUT TYPE=\"text\" NAME=\"alder\" size=\"3\" maxlength=\"3\"><br>
Description *<br><TEXTAREA NAME=\"profil\" ROWS=\"5\" COLS=\"23\"></TEXTAREA><br>
<INPUT TYPE=\"submit\" NAME=\"submit\" value=\"next >>\"><br>
Fields marked with a * <i>have to</i> be filled.</font>
</form>
</TD></TR></TABLE>
<?
} elseif ($mode == \'checknewuser\') {
if((!$navn) || (!$user) || (!$pass1) || (!$alder) || (!$profil)) {
$alert = \"You have to fill every field marked with a *.\";
$nextmode = \"checknewuser\";
} elseif($pass1 != $pass2) {
$alert = \"Check your passwords.\";
$nextmode = \"checknewuser\";
} else {
$alert = \"You are now about to complete the registration as user of the CoTT - Community of TechnoToilet, check the following informations again for failures.\";
$nextmode = \"newuserok\";
}
$indhold = \"<TABLE cellpadding=\\\"0\\\" cellspacing=\\\"0\\\" border=\\\"0\\\" style=\\\"text-align:left;\\\">\\n<TR><TD>\\n<font class=\\\"red\\\">\";
$indhold .= $alert;
$indhold .= \"</font>\\n\";
$indhold .= \"<br><form action=\\\"?mode=\";
$indhold .= $nextmode;
$indhold .= \"\\\" method=\\\"post\\\">\\n\";
$indhold .= \"Your name *<br><INPUT TYPE=\\\"text\\\" NAME=\\\"navn\\\" size=\\\"27\\\" value=\\\"$navn\\\">\\n<br>\";
$indhold .= \"Choose a username *<br><INPUT TYPE=\\\"text\\\" NAME=\\\"user\\\" size=\\\"27\\\" value=\\\"$user\\\"><br>\";
$indhold .= \"Password *<br><INPUT TYPE=\\\"password\\\" NAME=\\\"pass1\\\" size=\\\"27\\\" value=\\\"$pass1\\\">\\n<br>\";
$indhold .= \"Password again *<br><INPUT TYPE=\\\"password\\\" NAME=\\\"pass2\\\" size=\\\"27\\\" value=\\\"$pass2\\\"><p>\";
$indhold .= \"Adress<br><INPUT TYPE=\\\"text\\\" NAME=\\\"adresse\\\" size=\\\"27\\\" value=\\\"$adresse\\\"><br>\";
$indhold .= \"Postal code and city<br><INPUT TYPE=\\\"text\\\" NAME=\\\"postnr\\\" size=\\\"4\\\" value=\\\"$postnr\\\" maxlength=\\\"4\\\"> <INPUT TYPE=\\\"text\\\" NAME=\\\"city\\\" size=\\\"25\\\" value=\\\"$city\\\"><br>\";
$indhold .= \"Age *<br><INPUT TYPE=\\\"text\\\" NAME=\\\"alder\\\" size=\\\"3\\\" maxlength=\\\"3\\\" value=\\\"$alder\\\"><br>\";
$indhold .= \"Description *<br><TEXTAREA NAME=\\\"profil\\\" ROWS=\\\"5\\\" COLS=\\\"23\\\">$profil</TEXTAREA><br>\";
$indhold .= \"<INPUT TYPE=\\\"submit\\\" NAME=\\\"submit\\\" value=\\\"next >>\\\"><br></font>\";
$indhold .= \"Fields marked with a * <i>have to</i> be filled.</form></TD></TR></TABLE>\\n\";
print(\"$indhold\");
}
?>
</BODY>
</HTML>