[PHP] Variables + POST

Résolu/Fermé
Hacker?! Messages postés 137 Date d'inscription jeudi 25 décembre 2008 Statut Membre Dernière intervention 1 mai 2015 - Modifié par Hacker?! le 1/08/2011 à 19:16
Hacker?! Messages postés 137 Date d'inscription jeudi 25 décembre 2008 Statut Membre Dernière intervention 1 mai 2015 - 1 août 2011 à 21:23
Bonjour,

tout d'abord voici mes codes :
formulaire.php :
<hidden>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > 
<head> 
<title> C'est + ou - ?? 
</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
</head> 
<body bgcolor="yellow"> 
<center> 
<p> 
    <b><font color="blue">Choisis <font color="red"><i>u</i>n <font color="blue"><i>no</i>mbre <font color="red">en<i>tr</i>e <font color="blue">0 <font color="red">et <font color="blue">100 <font color="red">et <font color="blue">e<i>ss</i>aies <font color="red">de <font color="blue">tr<i>ou</i>ver <font color="red">la <font color="blue"><u>réponse:</u></b></font> 
</p> 

<form action="cible.php" method="post"> 
<p> 
    <input type="text" name="chiffre" /> 
    <input type="submit" value="Valider" /> 
</p> 
</form> 
<embed src="saw.mp3" autostart="true" loop="true" hidden="true"></embed> 
</center> 
</body> 
</html>


cible.php :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > 
<head> 
<title> C'est + ou - ?? 
</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
</head> 
<body bgcolor="yellow"> 
<center> 
<b> 
<font color="green"> 
<?php 
$aleratoire1 = ran(1,99); 

 if ($_POST['chiffre'] <= $aleratoire1) 
 { 
 echo "C'est Faux! Essaies un nombre plus GRAND !"; 
} 
elseif ($_POST['chiffre'] >= $aleratoire1) 
{ 
    echo "C'est Faux! Essaies un nombre plus PETIT !"; 
} 
elseif ($_POST['chiffre'] == $aleratoire1) 
{ 
    echo "C'est Bien, tu sais résoudre un jeu de gamin de 2 ans !"; 
} 
?> 
</font> 
<b> 
</center> 
</body> 
</html>


Dans cible.php, $aleratoire1 ne veut pas marcher, il me met une erreur. alors qu'avec un chiffre tout marche !

Vous pouvez m'aider. Merci d'avance !
A voir également:

1 réponse

dariumis Messages postés 571 Date d'inscription mardi 16 mars 2010 Statut Membre Dernière intervention 18 avril 2018 63
Modifié par dariumis le 1/08/2011 à 20:23
Salut, pour ton chiffre aléatoire tu devrais peut être essayer avec mt_rand();

$aleratoire1 = mt_rand(1,99); 


Edit ou peut être
rand()
ha ben ouais ta oublié le d.
0
Hacker?! Messages postés 137 Date d'inscription jeudi 25 décembre 2008 Statut Membre Dernière intervention 1 mai 2015 12
1 août 2011 à 21:23
Merci de ta réponse mais mon projet a été annulé :) !
0