PHP:can i put a variable inside a rand()?

Timothy K

New member
I cant seem to get this to work at all... i tried tons of stuff why wont the varible work??? im trying to get the user's selected dice to roll. if the user selects a 10 sided dice then it should role a random number 1-10 but it doesnt.

here is my HTML file minus the obvious..

<div id="box">

<img src="dice.png" width="150px">

<form method="post"
action="myphp.php">

<h3>please choose how many sides for the dice</h3>

<input type="text"
name="num"
value="">
<br><br>

<input type="submit"
value="roll">


</form>

</div>

here is my PHP file

<div id="box">


<?php

$num = $_REQUEST["$num"];
$roll = $_REQUEST["$roll"];


$roll = rand(1,$num);

print "your number is $roll";
?>

<a href="index.html">reroll!!</a>

</div>
 
Back
Top