forked from rebillar/site-accueil-insa
89 lines
No EOL
2.8 KiB
PHP
89 lines
No EOL
2.8 KiB
PHP
<?php
|
|
ob_start(); // Start reading html
|
|
|
|
include "script/db.php";
|
|
|
|
if(isset($_POST['send'])) {
|
|
if(!empty($_POST['answer']) AND !empty($_POST['team'])) {
|
|
|
|
$ans = htmlspecialchars($_POST['answer']);
|
|
$team = htmlspecialchars($_POST['team']);
|
|
|
|
$req = $db->query('SELECT answer, point, team FROM enigma WHERE id = 1'); //id = 1 est la ligne correspondant à l'énigme de la plaquette
|
|
$reponse = $req -> fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if($reponse[0]['team'] == NULL) {
|
|
//le "if" ici c'est parce que le 0 => $team = NULL du coup on doit genre faire une conversion relou
|
|
if($team == "pkpeach") {
|
|
$team = 0;
|
|
} elseif($team == "boomario") {
|
|
$team = 1;
|
|
} else {
|
|
header('Refresh: 0');
|
|
}
|
|
|
|
|
|
if($ans == $reponse[0]['answer']) {
|
|
$req = $db->prepare("INSERT INTO scores(texte, points, team) VALUES(?, ?, ?)");
|
|
$req->execute(array("enigme de la plaquette", $reponse[0]['point'], $team));
|
|
|
|
$req = $db->prepare("UPDATE enigma SET team = ? WHERE id = 1");
|
|
$req->execute(array($team));
|
|
?><script type="text/javascript">alert("Félicitation, vous avez fait gagner <?= $reponse[0]['point'] ?>points à votre équipe");</script><?php
|
|
} else {
|
|
$error = "Mauvaise réponse, try again !";
|
|
}
|
|
} else {
|
|
$error = "petit malin, la réponse à déjà été trouvé";
|
|
}
|
|
} else {
|
|
$error = "Il faut remplir tout les champs ;)";
|
|
}
|
|
}
|
|
?>
|
|
<div class="box-jaune">
|
|
<span class="corners corners-top"></span>
|
|
<span class="corners corners-bottom"></span>
|
|
|
|
<div class="title">Enigme de la plaquette</div>
|
|
|
|
<span class="circles circles-top"></span>
|
|
<span class="circles circles-bottom"></span>
|
|
</div>
|
|
|
|
<section>
|
|
<?php
|
|
$req = $db->query('SELECT team FROM enigma WHERE id = 1'); //id = 1 est la ligne correspondant à l'énigme de la plaquette
|
|
$reponse = $req -> fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
//var_dump($reponse);
|
|
if($reponse[0]['team'] == NULL) {
|
|
?>
|
|
<form method="POST">
|
|
<input type="text" placeholder="Réponse à l'énigme" name="answer" class="input">
|
|
<select name="team" class="input">
|
|
<option value="">Choisissez votre équipe</option>
|
|
<option value="pkpeach">PKpeach</option>
|
|
<option value="boomario">Boomario</option>
|
|
</select>
|
|
<input type="submit" name="send" value="Valider votre réponse" class="submit">
|
|
</form>
|
|
<?php
|
|
} else {
|
|
if($reponse[0]['team'] == 0) {
|
|
echo "La réponse de l'énigme de la plaquette à déja été trouvé par PKpeach !";
|
|
} else {
|
|
echo "La réponse de l'énigme de la plaquette à déja été trouvé Boomario !";
|
|
}
|
|
}
|
|
|
|
if(isset($error)) {
|
|
echo $error;
|
|
}
|
|
?>
|
|
</section>
|
|
|
|
<?php
|
|
$infopage = ["", "Enigma", ob_get_clean(), "", "enigma"]; //relativepath, pagetitle, pagecontent, pagescript, pagename | cf structure/template.php ligne 2 à 6
|
|
include("structure/template.php");
|
|
?>
|