2020-09-19 16:08:07 +02:00
< ? php
ob_start (); // Start reading html
2022-06-14 02:23:05 +02:00
include " script/db.php " ;
2022-06-12 21:45:19 +02:00
2023-01-26 15:53:45 +01:00
include " assets/scripts/globals.php "
2022-06-12 21:45:19 +02:00
$end = false ;
if ( isset ( $_POST [ 'send' ])) {
$req = $db -> query ( 'SELECT id, name FROM mot_croise' );
while ( $r = $req -> fetch ()) {
$input [ $r [ 'id' ]] = htmlspecialchars ( $_POST [ " input " . $r [ 'id' ]]);
if ( htmlspecialchars ( $_POST [ " input " . $r [ 'id' ]]) == $r [ 'name' ]) {
$color [ $r [ 'id' ]] = " green " ;
} elseif ( ! empty ( $_POST [ " input " . $r [ 'id' ]])) {
$color [ $r [ 'id' ]] = " red " ;
} else {
$color [ $r [ 'id' ]] = " grey " ;
}
}
$end = true ;
$i = 1 ;
while ( $end AND $i <= count ( $color )) {
if ( $color [ $i ] != " green " ) {
$end = false ;
}
$i ++ ;
}
2022-06-12 23:52:11 +02:00
$req = $db -> prepare ( " SELECT * FROM scores WHERE texte = ? " );
2022-06-13 18:41:47 +02:00
$req -> execute ( array ( " Mots croises " ));
2022-06-12 23:52:11 +02:00
$req_exist = $req -> rowCount ();
if ( $req_exist == 0 ) {
if ( $end ) {
2022-06-13 18:41:47 +02:00
if ( isset ( $_POST [ 'team' ]) AND ! empty ( $_POST [ 'team' ])) {
2022-06-12 23:52:11 +02:00
$team = htmlspecialchars ( $_POST [ 'team' ]);
2023-01-26 15:53:45 +01:00
if ( $team == $TEAM1 ) {
2022-06-12 23:52:11 +02:00
$team = 0 ;
2023-01-26 15:53:45 +01:00
} elseif ( $team == $TEAM2 ) {
2022-06-12 23:52:11 +02:00
$team = 1 ;
} else {
header ( 'Refresh: 0' );
}
2022-06-15 22:58:37 +02:00
$req = $db -> prepare ( " INSERT INTO scores(texte, points, team, id_staff) VALUES(?, ?, ?, ?) " );
$req -> execute ( array ( " Mots croises " , " 500 " , $team , 0 ));
2022-06-13 19:04:38 +02:00
?> <script type="text/javascript">alert("Félicitation, vous avez fait gagner 500points à votre équipe");</script><?php
2022-06-12 23:52:11 +02:00
}
}
}
2022-06-12 21:45:19 +02:00
}
2020-09-19 16:08:07 +02:00
?>
2022-06-12 16:12:39 +02:00
< main >
2023-01-22 12:46:06 +01:00
2020-09-19 16:08:07 +02:00
2023-01-22 12:46:06 +01:00
< br >
2022-06-12 21:45:19 +02:00
< section >
< img src = " assets/img/mot_croise.svg " class = " mot_croise " >
</ section >
< section >
< form method = " POST " >
2022-06-12 23:52:11 +02:00
Tout les mots doivent être indiqués en minuscule , sans accent , sans espaces ni caractères spéciaux .< br >< br >
2022-06-12 21:45:19 +02:00
< ? php
$req = $db -> query ( 'SELECT id FROM mot_croise' );
while ( $r = $req -> fetch ()) {
?>
2022-06-15 23:52:29 +02:00
< input type = " text " name = " input<?= $r['id'] ?> " placeholder = " Mot <?= $r['id'] ?> " value = " <?php if(isset( $input[$r['id'] ])) { echo $input[$r['id'] ]; } ?> " style = " border: 3px solid <?= $color[$r['id'] ] ?>; " class = " input " >
2022-06-12 21:45:19 +02:00
< ? php
}
2022-06-13 18:41:47 +02:00
$req = $db -> prepare ( " SELECT team FROM scores WHERE texte = ? " );
$req -> execute ( array ( " Mots croises " ));
2023-01-22 12:46:06 +01:00
// récupère le nb de résultats, si 0 => aucune equipe n'a terminé
2022-06-13 18:41:47 +02:00
$req_exist = $req -> rowCount ();
$team_gg = $req -> fetchAll ( PDO :: FETCH_ASSOC );
if ( $end AND $req_exist == 0 ) {
2022-06-12 23:52:11 +02:00
?> <br>
Franchement GG à vous , choisissez votre équipe ci - dessous pour lui faire remporter les points :< br >
2022-06-13 18:41:47 +02:00
< select name = " team " class = " input " >
2022-06-12 21:45:19 +02:00
< option value = " " > Choisissez votre équipe </ option >
2023-01-26 15:53:45 +01:00
< option value = " <?= $TEAM1 ?> " >< ? = $TEAM1 ?> </option>
< option value = " <?= $TEAM2 ?> " >< ? = $TEAM2 ?> </option>
2022-06-12 21:45:19 +02:00
</ select >
< ? php
}
2022-06-13 18:41:47 +02:00
?> <br><br>
< input type = " submit " name = " send " value = " Envoyer " class = " submit " >
2022-06-12 23:52:11 +02:00
< font color = " red " >
< ? php if ( isset ( $error )) {
echo $error ;
} ?>
</ font >
< br >< br >
< ? php
if ( $req_exist == 0 ) {
2022-06-17 13:51:52 +02:00
echo " Aucune des deux équipes n'a réussi à trouver tous les mots " ;
2022-06-12 23:52:11 +02:00
} else {
if ( $team_gg [ 0 ][ 'team' ] == 0 ) {
2023-01-26 15:53:45 +01:00
echo $TEAM1 . " à déjà tout trouvé " ;
2022-06-12 23:52:11 +02:00
} else {
2023-01-26 15:53:45 +01:00
echo $TEAM2 . " à déjà tout trouvé " ;
2022-06-12 23:52:11 +02:00
}
}
?>
2022-06-12 21:45:19 +02:00
</ form >
2022-07-10 10:34:35 +02:00
NB : Des indices se cachent peut - être sur le site , CTR + MAJ + I pourrais devenir ton meilleur ami .
2022-06-12 21:45:19 +02:00
</ section >
2022-06-12 16:12:39 +02:00
</ main >
2020-09-19 16:08:07 +02:00
< ? php
2023-01-22 12:46:06 +01:00
$infopage = [ " " , " Cahier de vacances " , ob_get_clean (), " " , " vacances " , " Mots croisés pour vous occuper pendant les vacances " ]; //relativepath, pagetitle, pagecontent, pagescript | cf structure/template.php ligne 2 à 6
2022-01-19 22:26:58 +01:00
include ( " structure/template.php " );
2020-09-19 16:08:07 +02:00
?>