-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajouter_ami.php
More file actions
66 lines (42 loc) · 1.14 KB
/
Copy pathajouter_ami.php
File metadata and controls
66 lines (42 loc) · 1.14 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
session_start();
try
{
$bdd = new PDO('mysql:host=localhost;dbname=projet_piscine_bdd;charset=utf8', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8/>
</head>
<body>
<?php
$Ami=isset($_POST["id_ami"])?$_POST["id_ami"]:"";
$_SESSION['ami1']=$Ami;
$requete="INSERT INTO `ami` (`id_ami`, `id_auteur1`, `id_auteur2`, `date_amitie`) VALUES (NULL, :id_auteur, :id_ami, CURTIME());";
$sql=$bdd->prepare($requete);
$sql->execute(array(
'id_auteur' => $_SESSION['id_auteur'],
'id_ami' => $_SESSION['ami1']));
$Prenom=$_SESSION['prenom'];
$Nom=$_SESSION['nom'];
$requetenotif="INSERT INTO `notification` (`id_notif`, `contenu_notif`, `date_notif`, `id_auteur`) VALUES (NULL, '$Prenom $Nom vous a ajouté', CURTIME(), :id_ami1);";
$sqlnotif=$bdd->prepare($requetenotif);
$sqlnotif->execute(array(
'id_ami1' => $_SESSION['ami1']));
header('Location: http://localhost/piscine/doc_piscine/accueil.php ');
?>
<script>
location.reload(true)
loadAccueil();
</script>
<?php
exit();
?>
</body>
</html>