Ver Mensaje Individual
  #6 (permalink)  
Antiguo 28/07/2011, 11:49
moro666
 
Fecha de Ingreso: mayo-2011
Mensajes: 214
Antigüedad: 13 años, 10 meses
Puntos: 16
Respuesta: Como crear un numero aleatorio una vez

<?php

if(!filter_has_var(INPUT_POST, "usrnum")){
$num=rand(1,100);
$_SESSION["num"]=$num;
}else{
$num1=$_SESSION["num"];
$usrnum = filter_input(INPUT_POST, "usrnum");
if($usrnum == $num1){
print("Correcto, has acertado el numero $num!");
$num=rand(1,100);
$_SESSION["num"]=$num;
}elseif($usrnum > $num1){
print("Tu numero es muy alto");
}elseif($usrnum < $num1){
print("Tu numero es muy bajo");
}
}
print <<<HERE
<form action="" method="post">
<fieldset>
<input name="usrnum" type="text" value="" />
<br />
<input type="submit" value="enviar" />
</fieldset>
</form>
HERE;
print($num);
?>

CONSEGUIDO!

P.D. Lo que me referia es que me pusieras un ejemplo, teoria me sobra ya"