Bonjour les amis,
Déja merci pour l'aide pour mon premier post ca m'as vraiment permis d'avancer.
Donc voila j'ai créé un script php (en prenant des aides par ci par la) et donc ce script permet de créé un repertoire téléphonique pour mes sip phones.
Voila mon problème, je voudrais pouvoir effacer l'élément nom de famille qui a comme variable $cnom, hors le script que j'ai fais ne fais rien et franchement je bloque.
CODE PHP pour l'ajout de contact dans le répertoire :
Puis CODE pour EFFACER une entrée :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 <?php if (isset($_POST['insert'])) { $xml = new DomDocument("1.0","UTF-8"); $xml->load('phonebook.xml'); $cname = $_POST['c_name']; $cnom = $_POST['c_nom']; $tphone = $_POST['t_phone']; $account = $_POST['a_count']; $groupe = $_POST['g_roupe']; $rootTag = $xml->getElementsByTagName("AddressBook")->item(0); $infoTag = $xml->createElement("Contact"); $nameTag = $xml->createElement("FirstName", $cname); $nomTag = $xml->createElement("LastName", $cnom); $genreTag = $xml->createElement("Phone"," "); $phoneTag = $xml->createElement("phonenumber", $tphone); $genreTag ->setAttribute("type","Work"); $accountTag = $xml->createElement("accountindex", $account); $groupeTag = $xml->createElement("downloaded", $groupe); $infoTag->appendChild($nameTag); $infoTag->appendChild($nomTag); $genreTag->appendChild($phoneTag); $infoTag->appendChild($genreTag); $infoTag->appendChild($accountTag); $infoTag->appendChild($groupeTag); $rootTag->appendChild($infoTag); $xml->save('phonebook.xml'); } ?> <html> <body> <form action="ajouter.php" method="post"> <h1>AJOUTER CONTACTS</h1></br> PRENOM <input type = "text" name = "c_name" /></br> NOM <input type = "text" name = "c_nom" /></br> TELEPHONE <input type = "text" name = "t_phone"/></br> COMPTE : <input type = "radio" name = "a_count" value="1" checked>1</br> GROUPE : <input type = "radio" name = "g_roupe" value="0" checked>0</br> <input type = "submit" name="insert" value = "ajouter"/> <input type="button" value="Accueil" onclick="document.location.href='index.html';"> </form> </body> </html>
Voila alors Mrsky me demande ce qui ne va pas, bin franchement y a rien qui s'efface après je sais pas ou ça coince, Merci par avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
26
27
28
29
30
31 <?php if (isset($_REQUEST['delete'])) { $xml = new DomDocument("1.0","UTF-8"); $xml->load('phonebook.xml'); $cnom = $_POST['c_nom']; $xpath=new DOMXPATH($xml); foreach($xpath->query("/AddressBook/Contact/FirstName[name='$cnom']") as $node) { $node->parentNode->removeChild($node); } $xml->formatoutput=true; $xml->save('phonebook.xml'); } ?> <html> <body> <form action="effacer.php" method="post"> <h1>EFFACER CONTACTS</h1></br> NOM <input type="text" name="c_nom" /></br> <input type="submit" name="delete" value="supprimer"></br> <input type="button" value="Accueil" onclick="document.location.href='index.html';"> </form> </body> </html>
Partager