-
Notifications
You must be signed in to change notification settings - Fork 0
/
update2.php
45 lines (35 loc) · 1.1 KB
/
update2.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
43
44
45
<?php
include_once 'services/AdminService.php';
include_once 'beans/Admin.php';
extract($_POST);
/*Local database
$host = 'localhost';
$dbname = 'platform';
$login = 'root';
$password = '';*/
//Remote Database
$host = 'remotemysql.com';
$dbname = 'QyAQjHlDFm';
$login = 'QyAQjHlDFm';
$password = 'DKSrKBVlQe';
try {
$con = new PDO("mysql:host=$host;dbname=$dbname", $login, $password);
$con->query("SET NAMES UTF8");
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
$image = $_FILES["photo"];
move_uploaded_file($image["tmp_name"], "dossiers/" . $image["name"]);
$id=$_POST['id'];
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$email=$_POST['email'];
$photo=$_FILES['photo']['name'];
if($photo != null){
$query = "UPDATE `administrator` SET `nom` = '$nom', `prenom` = '$prenom', `photo` = '$photo', `email` = '$email' WHERE `id` = $id ";
}else{
$query = "UPDATE `administrator` SET `nom` = '$nom', `prenom` = '$prenom', `email` = '$email' WHERE `id` = $id ";
}
$req = $con->prepare($query);
$req->execute() or die('Erreur dans votre code SQL');
header("location: admin.php");