Bonjour à tous, je n'arrive pas à faire une insertion c'est bête , en gros voilà mon code.
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 class add_film extends Film{ public function insert($nom, $type){ $pdo = $this->getPDO(); if($type == 'aventure') $type = '2'; else $type = '1'; $add = $pdo->prepare('INSERT INTO FILM (id_film,nom_film,id_cat) VALUES (:id_film,:nom_film,:id_cat)'); $id = $pdo->lastInsertId(); echo $id.$nom.$type; $add->execute(array ("id_film"=>$id,":nom_film"=>$nom,":id_cat"=>$type) ); if($add){ echo 'ok'; } else echo 'non'; $add->closeCursor(); } } $a = new add_film(); if (!(empty($_POST['nom']) && !(empty($_POST['type'])))){ $nom = $_POST['nom']; $type = $_POST['type']; $a->insert($nom,$type); }
Partager