Ok ho risolto!
A chi interessa posto la mia soluzione:
innanzitutto ho questo file registrazione2.php con i form di inserimento dati:
Codice PHP:
<?php
session_start();
?>
<form method="POST" action="registrazione3.php">
<table width="600" align="center" class="menu">
<tr>
<td colspan="2">Inserisci i dati richiesti per registrarti</td>
</tr>
<tr>
<td colspan="2">Al termine della registrazione, verrai reindirizzato alla pagina iniziale</td>
</tr>
</table>
<table align="center" class="testo">
<tr>
<td width="146">Login</td>
<td width="224"><input type="text" name="login" class="testo"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" class="testo"></td>
</tr>
<tr>
<td>Ripeti password</td>
<td><input type="password" name="ripetipassword" class="testo"></td>
</tr>
<tr>
<td>Nome</td>
<td><input type="text" name="nome" class="testo"></td>
</tr>
<tr>
<td>Cognome</td>
<td><input type = "text" name="cognome" class="testo"></td>
</tr>
<tr>
<td>Codice fiscale</td>
<td><input type = "text" name="codfiscale" class="testo"></td>
</tr>
<tr>
<td>Email</td>
<td><input type = "text" name="email" class="testo"></td>
</tr>
<tr>
<td>Telefono</td>
<td><input type = "text" name="tel" class="testo"></td>
</tr>
<tr>
<td align="center" class="testo"><input type="submit" value="Invia"></td>
<td align="center" class="testo"><input type="reset" value="Cancella"></td>
</tr>
</table>
</form>
Il tasto invia mi rimanda al file registrazione3.php in cui ho incluso queryregistrazione.php con questo codice:
Codice PHP:
<?php
session_start();
require('pg_connect.php');
?>
<link href="stili.css" rel="stylesheet" type="text/css" />
<table>
<tr>
<?php
#RECUPERO DELLE VARIABILI######################################################
$login = $_POST['login'];
$password = $_POST['password'];
$ripetipassword = $_POST['ripetipassword'];
$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$codfiscale = $_POST['codfiscale'];
$email = $_POST['email'];
$tel = $_POST['tel'];
#MESSAGGI DI ERRORE############################################################
#manca messaggio: "esiste già un nome di login così"
#if query(select from privato nomelogin where login="...") != 0 allora messaggio!!!
$mex = "";
if (empty($login)){
$mex = $mex . "[*]Non hai inserito il nome di login\n";
}
if (empty($password)){
$mex = $mex . "[*]Non hai inserito la password\n";
}
if (empty($ripetipassword)){
$mex = $mex . "[*]Non hai ripetuto la password\n";
}
if (empty($nome)){
$mex = $mex . "[*]Non hai inserito il nome\n";
}
if (empty($cognome)){
$mex = $mex . "[*]Non hai inserito il cognome\n";
}
if (empty($codfiscale)){
$mex = $mex . "[*]Non hai inserito il codice fiscale\n";
}
if(strlen($codfiscale)!=16 && !empty($codfiscale)){
$mex = $mex . "[*]Non hai inserito correttamente il codice fiscale\n";
}
if (empty($email)){
$mex = $mex . "[*]Non hai inserito l'indirizzo email\n";
}
if (empty($tel)){
$mex = $mex . "[*]Non hai inserito il numero di telefono\n";
}
if(!is_numeric($tel)){
$mex = $mex . "[*]Non hai inserito un numero di telefono valido\n";
}
if ($password != $ripetipassword){
$mex = $mex . "[*]Riscrivi la password in modo corretto\n";
}
if ($mex!=""){
$mex = "Attenzione torna indietro…\n" . $mex;
echo "<span class='testo'>" .$mex. "</span>";
?>
<form method="POST" action="registrazione.php"><input type="submit" value="Torna indietro"></form>
<?php
exit;
}
?>
</tr>
</table>
Così, in questo modo, riesco ad ottenere la mia pagina con gli errori in maniera decente!
Vi ringrazio per avermi dato qualche dritta!