Fejl i opret script
Nu har jeg kæmpet med at få et opret bruger script til at virke. Den vil godt tjekke oplysningerne 1 gang men der efter vil den ikke. Hvis alle oplysningerne er tastet ind vil ikke gemme oplysningerne i SQL databasen.Hvor er fejlen(e)?
<?
if (is_array($_GET))
{
$mode = $_GET['mode'];
$action = $_GET['action'];
}
require($_SERVER["DOCUMENT_ROOT"] . "/db.php");
if ($action == 'opretbruger')
{
$opret = $_REQUEST["opret"];
$nick = $_REQUEST["nick"];
$passowrd1 = $_REQUEST["passowrd1"];
$fornavn = $_REQUEST["fornavn"];
$efternavn = $_REQUEST["efternavn"];
$postnr = $_REQUEST["postnr"];
$by = $_REQUEST["by"];
$email = $_REQUEST["email"];
if ($opret == '1')
{
session_start();
if (isset($_SESSION['f']))
{
$_SESSION['fejlnick1'] = "off";
$_SESSION['fejlnick2'] = "off";
$_SESSION['fejlpassword1'] = "off";
$_SESSION['fejlpassword2'] = "off";
$_SESSION['fejlmail1'] = "off";
$_SESSION['fejlmail2'] = "off";
$_SESSION['f'] = "off";
}
$_SESSION['nick'] =$_REQUEST["nick"];
$_SESSION['password1'] = $_REQUEST["password1"];
$_SESSION['password2'] = $_REQUEST["password2"];
$_SESSION['fornavn'] = $_REQUEST["fornavn"];
$_SESSION['efternavn'] = $_REQUEST["efternavn"];
$_SESSION['postnr'] = $_REQUEST["postnr"];
$_SESSION['by'] = $_REQUEST["by"];
$_SESSION['email'] = $_REQUEST["email"];
if (empty($_SESSION['nick']))
{
$_SESSION['f'] = "on";
$_SESSION['fejlnick1'] = "on";
}
if ($_SESSION['nick'] > 0)
{
$brugt = mysql_query("SELECT * FROM users WHERE Nick = '$nick'");
if (mysql_num_rows($brugt) > 0)
{
$_SESSION['f'] = "on";
$_SESSION['fejlnick1'] = "off";
$_SESSION['fejlnick2'] = "on";
}
}
if (empty($_SESSION['password']))
{
$_SESSION['f'] = "on";
$_SESSION['fejlpassword1'] = "on";
}
elseif (!$_SESSION['password1'] == $_SESSION['password2'])
{
$_SESSION['f'] = "on";
$_SESSION['fejlpassword2'] = "on";
}
if (empty($_SESSION['email']))
{
$_SESSION['f'] = "on";
$_SESSION['fejlemail1'] = "on";
}
if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$", $_SESSION['email']))
{
$_SESSION['f'] = "on";
$_SESSION['fejlemail1'] = "off";
$_SESSION['fejlemail2'] = "on";
}
if ($_SESSION['f'] = "on")
{
$opret = '';
header('location: /bruger/opret.php?action=opretbruger');
}
else
{
mysql_query("INSERT INTO users (nick, passowrd, fornavn, efternavn, postnr, by, email) VALUES ('$nick', '$password1', '$fornavn', '$efternavn', '$postnr', '$by', '$email')");
mysql_close;
session_destroy() ;
header('Location: /');
}
}
else
{
session_start();
require($_SERVER["DOCUMENT_ROOT"] . "/design/top.php");
echo $_SESSION['f'];
?>
<FORM ACTION="/bruger/opret.php?action=opretbruger" METHOD="POST">
<TABLE BORDER="0">
<INPUT TYPE="hidden" NAME="opret" value="1">
<TR>
<TD ALIGN="center" COLSPAN='2'><B>Opret Bruger:</B></TD>
</TR>
<?
if (isset($_SESSION['fejlnick1']) && isset($_SESSION['f']))
{
?>
<TR>
<TD ALIGN="center" COLSPAN="2"><B><FONT COLOR="#FF0000">Du har ikke skrevet noget nick</FONT></B></TD>
<TR>
<?
}
if(isset($_SESSION['fejlnick2']) && isset($_SESSION['f']))
{
?>
<TR>
<TD ALIGN="center" COLSPAN="2"><B><FONT COLOR="#FF0000">Nicket er taget</FONT></B></TD>
<TR>
<?}?>
<TR>
<TD ALIGN="right">Nick:</TD>
<TD><INPUT TYPE="text" NAME="nick" value="<? echo $_SESSION['nick']; ?>"><font color='red'>*</font></TD>
</TR>
<?
if(isset($_SESSION['fejlpassword1']) && isset($_SESSION['f']))
{
?>
<TR>
<TD ALIGN="center" COLSPAN="2"><B><FONT COLOR="#FF0000">Du har ikke skrevet noget password</FONT></B></TD>
<TR>
<?
}
if(isset($_SESSION['fejlpassword2']) && isset($_SESSION['f']))
{
?>
<TR>
<TD ALIGN="center" COLSPAN="2"><B><FONT COLOR="#FF0000">De 2 password er ikke ens</FONT></B></TD>
<TR>
<?}?>
<TR>
<TD ALIGN="right">Password:</TD>
<TD><INPUT TYPE="text" NAME="password1"><font color='red'>*</font></TD>
</TR>
<TR>
<TD ALIGN="right">Password igen:</TD>
<TD><INPUT TYPE="text" NAME="password2"><font color='red'>*</font></TD>
</TR>
<TR>
<TD ALIGN="right">Fornavn:</TD>
<TD><INPUT TYPE="text" NAME="fornavn" value="<? echo $_SESSION['fornavn']; ?>"><font color='red'>*</font></TD>
</TR>
<TR>
<TD ALIGN="right">Efternavn:</TD>
<TD><INPUT TYPE="text" NAME="efternavn" value="<? echo $_SESSION['efternavn']; ?>"></TD>
</TR>
<TR>
<TD ALIGN="right">Adresse:</TD>
<TD><INPUT TYPE="text" NAME="adresse" value="<? echo $_SESSION['adresse']; ?>"></TD>
</TR>
<TR>
<TD ALIGN="right">Postnr:</TD>
<TD><INPUT TYPE="text" SIZE="3" MAXLENGTH="4" NAME="postnr" value="<? echo$_SESSION['postnr']; ?>"></TD>
</TR>
<TR>
<TD ALIGN="right">By:</TD>
<TD><INPUT TYPE="text" NAME="by" value="<? echo $_SESSION['by']; ?>"></TD>
</TR>
<?
if(isset($_SESSION['fejlemail1']) && isset($_SESSION['f']))
{
?>
<TR>
<TD ALIGN="center" COLSPAN="2"><B><FONT COLOR="#FF0000">Du har ikke skrevet nogen E-mail</FONT></B></TD>
<TR>
<?
}
if(isset($_SESSION['fejlemail1']) && isset($_SESSION['f']))
{
?>
<TR>
<TD ALIGN="center" COLSPAN="2"><B><FONT COLOR="#FF0000">Du har ikke skrevet en gyldig E-mail</FONT></B></TD>
<TR>
<?
}
?>
<TR>
<TD ALIGN="right">E-Mail</TD>
<TD><INPUT TYPE="text" NAME="email" value="<? echo $_SESSION['email']; ?>"><font color='red'>*</font></TD>
</TR>
<TR>
<TD ALIGN="center" colspan='2'><INPUT TYPE="submit" Value="Opret"><BR>(<font color='red'>*</font> Skal udfyldes)</TD>
</TR>
</TABLE>
</FORM>
<?
require($_SERVER["DOCUMENT_ROOT"] . "/design/bund.php");
}
}
else
{
?>
<a href='/bruger/opret.php?action=opretbruger'>opret</A>
<?
}
?>