Ho provato a fare un form per la registrazione, ho messo giusto qualche controllo tanto per, ovviamente dovrà essere perfezionato, l'unico problema è che non funziona... sapete dove ho sbagliato? Contate che questo è il mio primo approccio con il php
codice:
<?
$nome=$_POST['nome'];
$cognome=$_POST['cognome'];
$nick=$_POST['nick'];
$password=$_POST['password'];
$cpassword=$_POST['cpassword'];
$email=$_POST['email'];
$errore='';
$sep='|';
$control='true';
function ctrl_nome($nome)
{
for($i=0;$i<strlen($nome);$i++)
{
if(is_numeric($nome{i}))
$control=false;
} return $control;
}
function ctrl_psw($password,$cpassword)
{
if($password!=$cpassword)
$control=false;
return $control;
}
function ctrl_email($email)
{
if(!preg_match( '/^[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}$/', $email) and !empty($email))
$control=false;
return $control;
}
if(!ctrl_nome)
{ echo'ciao';
$errore=$errore.'Il nome non puo contenere numeri.';
}
if(!ctrl_psw)
{echo'ciao';
$errore=$errore.'Le password non coincidono.';
}
if (!ctrl_email)
$errore=$errore.' Email non corretta.';
if($errore=="")
{
$rigo=$nome.$sep.$cognome.$sep.$nick.$sep.$password.$sep.$email.$sep ;
$file=fopen(getenv('DOCUMENT_ROOT')."utenti.txt",'a');
fwrite($file,$rigo);
fclose($file);
}
else
echo $errore;
?>
<form method="POST" action="registrazione.php">
Nome <input type="text" name="nome" <? echo " value=\"".stripslashes($nome)."\""; ?>
Cognome <input type="text" name="cognome" <? echo " value=\"".stripslashes($cognome)."\""; ?>>
Nome Utente <input type="text" name="nick" <? echo " value=\"".stripslashes($nick)."\""; ?>>
Password <input type="password" name="password" <? echo " value=\"".stripslashes($password)."\""; ?>>
Conferma Password <input type="password" name="cpassword" <? echo " value=\"".stripslashes($cpassword)."\""; ?>>
E-mail<input type="email" name="email" <? echo " value=\"".stripslashes($email)."\""; ?>>
Registrati <input type="submit" name="registrati" value="submit">
</form>