Ciao a tutti,
ho un form che mi stampa i dati in un file di testo (nome, cognome, email).
Non riesco a impedire all'utente l'inserimento multiplo, ovvero ripetere lo stesso nome, cognome e email.
Questi i file (in rosso lo script in questione):

FORM:
Codice PHP:
<form action="replay.php" method="post">
<
input type="text" name="var1">
<
input type="text" name="var2">
<
input type="text" name="var3">
<
input type="submit" value="Invia">
</
form

SCRIPT:
Codice PHP:
<?
$filelocation
="dati.txt";

if (!
file_exists($filelocation)) {
    
$newfile fopen($filelocation,"w+");
    
fclose($newfile);
    }
$lines array_map('rtrim'file$filelocation ));
for ( 
$key 0$key count($lines); $key++ ) {
  if ( 
$lines[$key] == ($_POST['var1'] . " " $_POST['var2'] . " - " $_POST['var3'] . "
"
)) {
    
$found 1;
  }
}

$_POST['var1'] = stripslashes($_POST['var1']); 
$_POST['var2'] = stripslashes($_POST['var2']);
$_POST['var3'] = stripslashes($_POST['var3']);
?>

REPLAY:
Codice PHP:
<?php
$var1
=$_POST['var1'];
$var2=$_POST['var2'];
$var3=$_POST['var3'];
if (
$var1 == "" || (eregi("[0-9]"$var1)))
    {
    echo 
"Attenzione! Non hai compilato il campo 'Nome'" ;
}
elseif (
$var2 == "" || (eregi("[0-9]"$var2)))
    {
    echo 
"Attenzione! Non hai compilato il campo 'Cognome'" ;
}
elseif (
$var3 == "" || (!ereg(".+\@.+\..+"$var3)) || (!ereg("^[a-zA-Z0-9_@.-]+$"$var3)))
    {
    echo 
"Attenzione! Non hai compilato il campo 'Email'" ;
}
else
    {
    if (
$found==1){
        echo 
"ATTENZIONE, HAI GIA' INSERITO QUESTI DATI!";
    }
    elseif ( 
$f fopen($filelocation"a+") ) {
       
fwrite($f$_POST['var1'] . " " $_POST['var2'] . " - " $_POST['var3'] . "\n"); 
       
fclose($f);
       echo 
"Dati inseriti!";
    }
}
?>
:master: