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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
<?php
$bdd = new PDO('mysql:host=localhost;dbname=espace_membre', 'root', '');
if(isset($_POST['valider'])) {
$reponse = htmlspecialchars($_POST['reponse']);
if(!empty($_POST['reponse'])){
$reponselength = strlen($reponse);
if($reponselength <= 255) {
if($reponse == 3) {
$erreur = "Right answer";}
else {
$erreur = "Wrong answer" ;
}
} else {
$erreur = "Your answer must not exceed 255 print";
}
} else {
$erreur = "Your answer is empty";
}
}
?>
<html>
<head>
<meta charset="utf-8" />
<title>Quiz</title>
</head>
<body style="background-color: #FFD700; text-align: center;" >
<div>
<h1> Questions </h1>
<div>
<p> <TABLE BORDER="1" style="margin: auto; width: 1000px; height: 900px;">
<TR>
<TH> </TH>
<TH> Nom </TH>
<TH> Age </TH>
<TH> Pays </TH>
<TH> Question </TH>
<TH>Réponse à la question </TH>
</TR>
<TR>
<TH> Question 1 </TH>
<TD> </TD>
<TD> </TD>
<TD> </TD>
<TD> </TD>
<TD style="width: 200px; height: 276px;">
<label for="reponse">Votre réponse :</label>
<input type="text" placeholder="Votre réponse" id="reponse" name="reponse" value="<?php if(isset($rep)) { echo $rep; } ?>" />
<br />
<input type="submit" name="valider" value="Valider ma réponse" />
</TD>
</TR>
<TR>
<TH> Question 2 </TH>
<TD> </TD>
<TD> </TD>
<TD> </TD>
<TD> </TD>
<TD> <label for="reponse">Votre réponse :</label>
<input type="text" placeholder="Votre réponse" id="reponse" name="reponse" value="<?php if(isset($rep2)) { echo $rep2; } ?>" />
<br />
<input type="submit" name="valider2" value="Valider ma réponse" /> </TD>
</TR>
<TR>
<TH> Question 3 </TH>
<TD> </TD>
<TD> </TD>
<TD> </TD>
<TD> </TD>
<TD> <label for="reponse">Votre réponse :</label>
<input type="text" placeholder="Votre réponse" id="reponse" name="reponse" value="<?php if(isset($rep3)) { echo $rep3; } ?>" />
<br />
<input type="submit" name="valider3" value="Validate ma réponse" /> </TD>
</TR>
</TABLE></p></div>
<?php
if(isset($erreur)) {
echo '<font color="red">'.$erreur."</font>";
}
?>
</div>
</body>
</html> |
Partager