-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraitement.php
43 lines (37 loc) · 1.46 KB
/
traitement.php
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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$tableau = array(
"database" => array(
"host" => 'localhost' ,
"user" => 'root' ,
"password" => 'root' ,
"dbname" => 'alloFilms'
)
);
$dbconfig = $tableau['database'];
/* Connection à la base de donnée. */
try {
$bdd = new PDO('mysql:host=' . $dbconfig['host'] . ';dbname=' . $dbconfig['dbname'] . ';charset=utf8', $dbconfig['user'],$dbconfig['password'],
/*pour activer les erreurs requetes sql*/
array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )
);
} catch (Exception $e){
die('Erreur : ' . $e->getMessage());
}
$reponse = $bdd->prepare('SELECT * FROM users');
$reponse->execute();
// INSERT...................................................................
if(isset($_POST['ajout'])){ // ajout = name du bouton
$user_username = $_POST['user_username'];
$user_mail = $_POST['user_mail'];
$user_password = $_POST['user_password'];
$insert = $bdd->prepare('INSERT INTO users(user_username, user_mail, user_password) VALUES (:user_username, :user_mail, :user_password )');
$insert->bindParam(":user_username", $user_username, PDO::PARAM_STR);
$insert->bindParam(":user_mail", $user_mail, PDO::PARAM_STR);
$insert->bindParam(":user_password", $user_password, PDO::PARAM_STR);
$insert->execute();
header('Location: inscription.php');
}
$reponse->closeCursor(); // Termine le traitement de la requête
?>