1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <form action="Recherche.php" method="post">
<p>
<input type="text" name="nom" /> <input type="submit" value="Valider" />
</p>
</form>
<?
error_reporting(E_ALL);
// on récupère le nom si existe, sinon FAUX
$nom = isset($_POST['nom']) ? $_POST['nom'] : false;
$file = "Annuaire.csv";
if ( $nom ) { // si un nom (!!! autre que '' ou '0' ou 'null' !!!)
$fp = fopen($file, 'rt') or die('erreur ouverture fichier');
$i = 0;
while( ($csv = fgetcsv($fp)) or !feof($fp) ) { // on récupère un tableau pour chaque ligne
if( in_array($nom, $csv) ) var_export($csv);
//else echo "Le nom que vous recherchez n'a pas été trouvé";
$i++;
}
fclose($fp);
}
?> |
Partager