Projet php

Bonjour,
J'ai un projet de gestion des contacts en php, j'ai fais le squellete du projet je peux ajouter de nouveaux contacts, consulter les contacts mais il me reste a faire a modifier, supprimer et recherchere un contact.
Si quelqu'un peux m'aider a resoudre ce probleme

pour la consulation voici le code

$fichier='contact.txt';
$fich=fopen($fichier,"r");
while(!feof($fich))
{
$contact=fgets($fich);
$tab=explode("|",$contact);
echo"<tr>";
echo"<td><strong>".$tab[0]."</strong></td>";
echo"<td><strong>".$tab[1]."</strong></td>";
echo"<td><strong>".$tab[2]."</strong></td>";
echo"<td><strong>".$tab[3]."</strong></td>";
echo"<td><strong>".$tab[4]."</strong></td>";
echo"<td><strong>".$tab[5]."</strong></td>";
echo"</tr>";
}
echo"</table>";
fclose($fich);
?>

et pour l'ajout de contacts:
<?php
$identifiant=$_POST["identifiant"];
$nom=$_POST["nom"];
$prenom=$_POST["prenom"];
$adresse=$_POST["adresse"];
$telephone=$_POST["telephone"];
$mail=$_POST["mail"];

$f=fopen("contact.txt","a");
if($f!=false){
fputs($f,$identifiant."|".$nom."|".$prenom."|".$adresse."|".$telephone."|".$mail."\n");
}
fclose($f);
Configuration: Windows XP Internet Explorer 7.0

1 réponse

  1. pour la suppression
    $fichier='contact.txt';
    $delete = "toto";
    $tmp = array();
    $fich=fopen($fichier,"r"); 
    while(!feof($fich)) {
       $contact=fgets($fich); 
       if (strstr ($contact, $delete) !== false){
           $tmp[] = $contact;
       }
    }
    fclose($fich); 
    
    $fich=fopen($fichier,"w");
    foreach($tmp AS $string){
       fputs($string."\n"); 
    }
    fclose($fich); 
    
    


    à 2/3 trucs sa devrai etre sa

    pour modifier c'est pareil, juste à ajouter un else