forked from Kccorp/PA_2021_ESGI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addToTeam.php
49 lines (39 loc) · 1.4 KB
/
addToTeam.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
46
47
48
49
<?php
session_start();
require "functions.php";
if (isset($_POST["option"])) {
$option=$_POST["option"];
echo "<pre>";
print_r($option);
echo "</pre>";
$connection=connectDB();
foreach ($option as $key => $value) {
$queryPrepared=$connection->prepare("SELECT id_user, email, username FROM ".PRE."User WHERE username = :username;");
$queryPrepared -> execute(["username"=>$value]);
$info_user= $queryPrepared->fetch(PDO::FETCH_ASSOC);
echo "<pre>";
print_r($info_user);
echo "</pre>";
$queryPrepared=$connection->prepare("INSERT INTO ".PRE."TeamUser (User,Team) VALUES ( :id_user, :id_team);");
$queryPrepared -> execute(["id_user"=>$info_user["id_user"], "id_team"=>$_SESSION["team"]["id_team"]]);
$message = '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Invitation à une partie</title>
</head>
<body>
<p>
Bonjour, l equipe '.$_SESSION["team"]["name"].' vous invite à jouer avec vous à '.$_SESSION["team"]["game"].'
</p>
<p> Pour les rejoindrent rendez-vous sur https://play.kccorp.fr </p>
</body>
</html>';
sendMail($info_user["email"],$message);
header("Location: EditTeam2.php?name=".$_SESSION["team"]["name"]);
die();
}
} else {
header("Location: index.php");
}
;
?>