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
| $PDO = new PDO('mysql:host=localhost;dbname=philippe','root','');
$PDO->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_OBJ);
$lieudepart = htmlentities($_POST['lieudepart']);
$lieuarrive = htmlentities($_POST['lieuarrive']);
$participation = $_POST['participation'];
$datedepart = $_POST['datedepart'];
$datearrive = $_POST['datearrive'];
$sql = "INSERT INTO orders (conducteur, lieudepart, lieuarrive, participation, datedepart, datearrive) VALUES (:conducteur,:lieudepart,:lieuarrive,:participation,:datedepart,:datearrive)";
try {
$req = $PDO->prepare($sql);
$req->execute(array(
"conducteur" => "anatta",
"lieudepart" => $lieudepart,
"lieuarrive" => $lieuarrive,
"participation" => $participation,
"datedepart" => $datedepart,
"datearrive" => $datearrive
));
}
catch(PDOException $e){//Notez PDOException et pas seulement Exception
die("Erreur d'insertion :".$e->getMessage());
} |
Partager