Salve a tutti.
Vi scrivo in merito ad uno script per gestione utenti che sto creando.
Ho un problema. Questo è il mio code:
Perchè se un campo è vuoto non funge nulla e se sono tutti ok non include la pagina add_user.php?
Suppongo abbia sbagliato qualcosa, ma non so cosa...
Help plz!
Vi scrivo in merito ad uno script per gestione utenti che sto creando.
Ho un problema. Questo è il mio code:
PHP:
if ($step == "1") {
?>
<form action="index.php?page=register&step=2" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><br>
Username:<br>
<?php if ($error == "1") { print ("<b>Il campo è vuoto</b>\n"); } ?>
<br> </td>
<td><input name="form_username" type="text" size="30"></td>
</tr>
<tr>
<td><br>
Password:<br>
<?php if ($error == "2") { print ("<b>Il campo è vuoto</b>\n"); } ?>
<br> </td>
<td><input name="form_password1" type="password" size="30"></td>
</tr>
<?php if ($error == "4") { print ("<tr><td colspan=\"2\"><b>Le password non corrispondono</b></td></tr>\n"); } ?>
<tr>
<td><br>
Ripeti la Password:<br>
<?php if ($error == "3") { print ("<b>Il campo è vuoto</b>\n"); } ?>
<br> </td>
<td><input name="form_password2" type="password" size="30"></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td><br>
E-mail:<br>
<?php if ($error == "5") { print ("<b>Il campo è vuoto</b>\n"); } ?>
<br> </td>
<td><input name="form_mail" type="text" size="30"></td>
</tr>
<tr>
<td><br>
Nome reale:<br>
<?php if ($error == "6") { print ("<b>Il campo è vuoto</b>\n"); } ?> <br> </td>
<td><input name="form_nome" type="text" id="form_nome" size="30"></td>
</tr>
<tr>
<td><br>
Cognome reale:<br>
<?php if ($error == "7") { print ("<b>Il campo è vuoto</b>\n"); } ?> <br> </td>
<td><input name="form_cognome" type="text" id="form_cognome" size="30" maxlength="30"></td>
</tr>
<tr>
<td><br>
Società:<br>
<?php if ($error == "8") { print ("<b>Il campo è vuoto</b>\n"); } ?> <br> </td>
<td><input name="form_societa" type="text" id="form_societa" size="30"></td>
</tr>
<tr>
<td colspan="2"> <div align="center">
<table width="50%" border="0" cellspacing="15" cellpadding="0">
<tr>
<td><div align="center">
<input type="submit" name="Submit" value="Registra nuovo utente">
</div></td>
<td><div align="center">
<input type="submit" name="Submit2" value="Cancella tutto">
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</form>
<?php } elseif ($step == "2") {
// controllo che il campo username non sia vuoto
if ($form_username == "") {
header ("location: index.php?page=register&step=1&error=1");
exit;
}
// controllo che il campo password1 non sia vuoto
elseif ($form_password1 == "") {
header ("location: index.php?page=register&step=1&error=2");
exit;
}
// controllo che il campo password2 non sia vuoto
elseif ($form_password2 == "") {
header ("location: index.php?page=register&step=1&error=3");
exit;
}
// controllo che le due password corrispondano
elseif ($form_password1 != $form_password2) {
header ("location: index.php?page=register&step=1&error=4");
exit;
}
// controllo che il campo mail non sia vuoto
elseif ($form_mail == "") {
header ("location: index.php?page=register&step=1&error=5");
exit;
}
// controllo che il campo nome non sia vuoto
elseif ($form_nome == "") {
header ("location: index.php?page=register&step=1&error=6");
exit;
}
// controllo che il campo cognome non sia vuoto
elseif ($form_cognome == "") {
header ("location: index.php?page=register&step=1&error=7");
exit;
}
// controllo che il campo societa non sia vuoto
elseif ($form_societa == "") {
header ("location: index.php?page=register&step=1&error=8");
exit;
}
else {
include ("add_user.php");
}
}
Perchè se un campo è vuoto non funge nulla e se sono tutti ok non include la pagina add_user.php?
Suppongo abbia sbagliato qualcosa, ma non so cosa...
Help plz!