-
Notifications
You must be signed in to change notification settings - Fork 0
/
accept.php
38 lines (30 loc) · 1.17 KB
/
accept.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
<?php session_start();
if (!isset($_SESSION['pseudo']) || !isset($_GET['pseudo'])) {header('Location:index.php');}
require_once'cnx.php';
$pseudo=addslashes($_GET['pseudo']);
$ally = $bdd->prepare('SELECT id_alliance,apply FROM membres WHERE pseudo=?');
$ally->execute(array($pseudo));
$donnees = $ally->fetch();
$req=$bdd->prepare('SELECT id_alliance FROM membres WHERE id=?');
$req->execute(array($_SESSION['id']));
$check = $req->fetch();
$req2=$bdd->prepare('SELECT chef,nbr_membre FROM alliance WHERE id=?');
$req2->execute(array($check['id_alliance']));
$test = $req2->fetch();
if ($donnees['id_alliance']==$check['id_alliance'] && $donnees['apply']==0 && $test['chef']==$_SESSION['pseudo'])
{
if($test['nbr_membre']>=14)
{
$req3=$bdd->prepare('UPDATE membres SET id_alliance=0 WHERE id_alliance=? AND apply=0');
$req3->execute(array($check['id_alliance']));
}
$req3=$bdd->prepare('UPDATE membres SET apply=1 WHERE pseudo=?');
$req3->execute(array($pseudo));
$req3=$bdd->prepare('UPDATE alliance SET nbr_membre=nbr_membre+1 WHERE id=?');
$req3->execute(array($donnees['id_alliance']));
header('Location:alliance.php');
}
else
{
header('Location:alliance.php');
}