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++;
}
$req = $db->prepare("SELECT * FROM scores WHERE texte = ?");
$req->execute(array("Mots croises"));
$req_exist = $req->rowCount();
if($req_exist == 0) {
if($end) {
if(isset($_POST['team']) AND !empty($_POST['team'])) {
$team = htmlspecialchars($_POST['team']);
if($team == $TEAM1) {
$team = 0;
} elseif($team == $TEAM2) {
$team = 1;
} else {
header('Refresh: 0');
}
$req = $db->prepare("INSERT INTO scores(texte, points, team, id_staff) VALUES(?, ?, ?, ?)");
$req->execute(array("Mots croises","500", $team, 0));
?>
NB : Des indices se cachent peut-être sur le site, CTR+MAJ+I pourrais devenir ton meilleur ami.