$cid = $_POST['cid']; $cm->deleteContact($mysql, $cid, $uid); } break; } case 'Save' : { if(!isset($_POST['cname'])) echo "<p>The contact cannot be empty.</p>"; else { $name = $_POST['cname']; $email = $_POST['email']; $phone = $_POST['phone']; $cid = $_POST['cid']; if($cid == 0) $cm->addContact($mysql, $name, $email, $phone, $uid); else $cm->updateContact($mysql, $cid, $name, $email, $phone, $uid); } break; } default : } } $cm->viewContacts($uid, $mysql); echo <<<FOOTER <div id="footer"><p>Powered by enhanCSE 2011</p></div> </body> </html>
<?php header('Content-Type: application/json'); //indique que le retour doit $etre traité en json require './liste_include_ajax.php'; require '../classes/connexion.class.php'; require '../classes/contact.class.php'; require '../classes/contactManager.class.php'; $db = Connexion::getInstance($dsn, $user, $pass); try { $mg = new ContactManager($db); $retour = $mg->addContact($_GET); print json_encode(array('retour' => $retour)); } catch (PDOException $e) { }