Search This Blog

roll dice in php

roll_dice.php :

<center><?php
$rand=rand(1,6);
echo "dice one : $rand".'<br>';
$rand1=rand(1,6);
echo "dice two : $rand1";

?>
<form action="roll_dice.php" method="POST">
<input type="submit" value="roll dice">
</form>


output :

dice one : 3
dice two : 3

dice one : 3
dice two : 5

dice one : 4
dice two : 2

dice one : 4
dice two : 3

dice one : 1
dice two : 5

note :
for basics : rand()

Share Links

Related Posts Plugin for WordPress, Blogger...