www.kainard.altervista.org/esercizio.2
c'è la pagina, ecco il codice
Codice PHP:
<html>
<head>
<style type="text/css">
#form {
width: 250px;
color: blue;
font: 12px bold Verdana;
}
input {
border: 1px dashed blue;
background: white;
height: 25px;
color: blue;
font: 12px bold Verdana;
height: 20px;
}
.tasto {
border: 1px solid blue;
}
</style>
</head>
<body>
<?php
$nome = $_POST["nome"];
$cognome = $_POST["cognome"];
$pass = $_POST["pass"];
$pass2 = $_POST["pass2"];
$mail = $_POST["mail"];
$err1 = 0;
$err2 = 0;
$err3 = 0;
$err4 = 0;
$err5 = 0;
if ( strlen($nome) <= 2 ) { $err1 = 1; }
if ( strlen($cognome) <= 2 ) { $err2 = 1; }
if ( strlen($nome) <= 4 ) { $err3 = 1; }
if ( strlen($nome) <= 4 ) { $err4 = 1; }
// [email]abcd@abcd.ab[/email]
$poschiocc = strpos($mail,'@');
//ottengo la posizione della chiocciola
$pospunto = strpos($mail,'.');
//ottengo la posizione del punto
$prova = substr($mail,0,$poschiocc);
$prova2 = substr($mail,$poschiocc+1,$pospunto-$poschiocc-1);
$prova3 = substr($mail,$pospunto+1,strlen($mail));
if ( ( strlen($prova) <= 3 ) || ( strlen($prova2) <= 3 ) || ( strlen($prova3) <= 1 ) || ( $mail == "" ) ) { $err5 = 1; }
?>
<form action="esercizio2.php" method="post" id="form">
Nome <input type="text" name="nome">
Cognome <input type="text" name="cognome">
Password <input type="password" name="pass">
Password <input type="password" name="pass2">
Email <input type="text" name="mail">
<input type="submit" name="submit" value="Invia dati" class="tasto">
<input type="reset" name="reset" value="Resetta" class="tasto">
<?php
if ( isset($_POST["submit"]) ) {
if ( ($err1 == 1 ) || ($err2 == 1) || ($err3 == 1) || ($err4 == 1) || ($err5 == 1) ) {
if ($err1 == 1 ) { echo("
Devi correggere il nome"); }
if ($err2 == 1 ) { echo("
Devi correggere il cognome"); }
if ($err3 == 1 ) { echo("
Devi correggere la pass"); }
if ($err4 == 1 ) { echo("
Devi correggere la 2 pass"); }
if ($err5 == 1 ) { echo("
Devi correggere l'email"); }
}
else { echo("
Modulo inviato correttamente"); }
}
else { echo("
Devi compilare il modulo"); }
?>
</form>
</body>
</html>