Salut,
J'ai suivi le tutoriel d'aide pour la création d'un sondage (qui semble très pratique, en effet) et modifié légèrement le code pour donner ceci :
<html>
<head>
<title>
Êtes-vous d'accord ?
</title>
</head>
<body>
<form name="formulaire" method="post" action="<?=$_SERVER['$PHP_SELF']?>">
<input type="radio" name="choix" value="oui"> Pour.
<input type="radio" name="choix" value="non"> Neutre.
<input type="radio" name="choix" value="pas"> Contre.
<input type="submit" value="Envoyer">
</form>
<?
switch($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;
}
?>
<?
$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 \"pour\" : ",$sonda;
echo "Nombre de \"contre\" : ",$sondb;
echo "Nombre de \"neutre\" : ",$sondc;
echo "Nombre total de votes : ",$tot_sond;
?>
</body>
</html>
Y a-t-il un problème ? Lorsque j'envoie un vote, pourtant, ça ne fonctionne pas : ça reste à zéro. J'ai bien créer un page .php que j'ai nommée test (test.php) et les trois pages .txt réglementaires.
Besoin d'aide au plus vite,
je vous remercie d'avance. #clin#