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
| <html lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Untitled</title>
</head>
<body>
Question : "L'arc cosinus, c'est une herbe aromatique ?"
<form name="formulaire" method="post" action="<?php echo $PHP_SELF;?>">
<input type="radio" name="choix" value="oui"> oui...
<input type="radio" name="choix" value="non"> non...
<input type="radio" name="choix" value="pas"> ne sait pas...
<input type="submit" value="Validez votre réponse">
</form>
<?php
switch($_POST['choix']){
case "oui":
$fichier = fopen("oui.txt","r+");
$sond = fgets($fichier,255);
$sond++;fclose($fichier);
$fichier = fopen("oui.txt","w");
fwrite($fichier,$sond);
fclose($fichier);break;
case "non":
$fichier = fopen("non.txt","r+");
$sond = fgets($fichier,255);
$sond++;fclose($fichier);
$fichier = fopen("non.txt","w");
fwrite($fichier,$sond);
fclose($fichier);break;
case "pas":
$fichier = fopen("pas.txt","r+");
$sond = fgets($fichier,255);
$sond++;fclose($fichier);
$fichier = fopen("pas.txt","w");
fwrite($fichier,$sond);
fclose($fichier);break;
}
?>
<?php
$fichier = fopen("oui.txt","r");
$sonda = fgets($fichier,255);
fclose($fichier);
$fichier = fopen("non.txt","r");
$sondb = fgets($fichier,255);
fclose($fichier);
$fichier = fopen("pas.txt","r");
$sondc = fgets($fichier,255);
fclose($fichier);
$tot_sond=($sonda+$sondb+$sondc);
echo "Nombre de \"oui\" : ",$sonda;
echo "Nombre de \"non\" : ",$sondb;
echo "Nombre de \"ne sait pas\" : ",$sondc;
echo "Nombre total de votes : ",$tot_sond;
?>
</body>
</html> |
Partager