2021-07-28 22:03:33 +02:00
< ? php
2022-01-19 22:26:58 +01:00
ob_start (); // Start reading html
2022-06-12 13:49:12 +02:00
2022-06-14 02:23:05 +02:00
include " script/db.php " ;
2023-01-26 15:53:45 +01:00
include " assets/scripts/globals.php "
2022-06-14 02:23:05 +02:00
2022-06-12 13:49:12 +02:00
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
2023-01-26 15:53:45 +01:00
if ( $team == $TEAM1 ) {
2022-06-12 13:49:12 +02:00
$team = 0 ;
2023-01-26 15:53:45 +01:00
} elseif ( $team == $TEAM2 ) {
2022-06-12 13:49:12 +02:00
$team = 1 ;
} else {
header ( 'Refresh: 0' );
}
if ( $ans == $reponse [ 0 ][ 'answer' ]) {
2022-06-15 22:58:37 +02:00
$req = $db -> prepare ( " INSERT INTO scores(texte, points, team, id_staff) VALUES(?, ?, ?, ?) " );
$req -> execute ( array ( " enigme de la plaquette " , $reponse [ 0 ][ 'point' ], $team , 0 ));
2022-06-12 13:49:12 +02:00
$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 ;) " ;
}
}
2021-07-28 22:03:33 +02:00
?>
2022-07-17 20:04:21 +02:00
2023-04-22 18:47:14 +02:00
< div class = " zone_txt " >
2022-06-12 13:49:12 +02:00
< ? 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 " >
2022-06-13 18:41:47 +02:00
< input type = " text " placeholder = " Réponse à l'énigme " name = " answer " class = " input " >
< select name = " team " class = " input " >
2022-06-12 13:49:12 +02:00
< option value = " " > Choisissez votre équipe </ option >
2023-01-26 15:53:45 +01:00
< ? php
echo " <option value= " . $TEAM1 . " > " . $TEAM1 . " </option> "
echo " <option value= " . $TEAM2 . " > " . $TEAM2 . " </option> "
?>
2022-06-12 13:49:12 +02:00
</ select >
2022-06-13 18:41:47 +02:00
< input type = " submit " name = " send " value = " Valider votre réponse " class = " submit " >
2022-06-12 13:49:12 +02:00
</ form >
< ? php
} else {
2022-06-13 19:04:38 +02:00
if ( $reponse [ 0 ][ 'team' ] == 0 ) {
2023-01-26 15:53:45 +01:00
echo " La réponse de l'énigme de la plaquette à déja été trouvé par " . $TEAM1 . " ! " ;
2022-06-13 19:04:38 +02:00
} else {
2023-01-26 15:53:45 +01:00
echo " La réponse de l'énigme de la plaquette à déja été trouvé " . $TEAM2 . " ! " ;
2022-06-13 19:04:38 +02:00
}
2022-06-12 13:49:12 +02:00
}
if ( isset ( $error )) {
echo $error ;
}
?>
2023-04-22 18:47:14 +02:00
</ div >
2021-07-28 22:03:33 +02:00
< ? php
2023-01-22 12:46:06 +01:00
$infopage = [ " " , " Enigma " , ob_get_clean (), " " , " enigma " , " Enigme de la plaquette " ]; //relativepath, pagetitle, pagecontent, pagescript, pagename | cf structure/template.php ligne 2 à 6
2022-01-19 22:26:58 +01:00
include ( " structure/template.php " );
2021-07-28 22:03:33 +02:00
?>