The php section of my code is not doing the correct operations when the user submits his/her number, for example, if the user submits 5, I want the rand function to randomly output 5 as the number selected; however, my code sometimes works and at other times does not work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
choose a die number
</title>
</head>
<center>
<body>
<h1>Choose a die number</h1>
<form method = "post" action="choosedie.php"/>
<!--If the user selects a number of sides the die is suppose to have
rand should go through and pick the number randomly, and echo out the
number that was entered by the user-->
Please choose how many sides a die should have from 1 through 6:
<br/>
<input type = "text" name = "roll"/>
<?php
//Roll a random dice from 1 through 6:
$roll = rand(1,6);
// Add random variable to do comparison on.
Bana sadece başka bir değişken oluşturmak zorunda kalmadan, burada rand karşılaştırmak için bir yol var mı?
$random = rand(1,6);
// If $roll is equal to $random echo the output out to the user.
If ($roll == $random)
{
echo "<br/>Here is the random $roll with the appropriate maximum value $random\n";
Kullanıcı 5 seçerse, ben bu 5 dışarı yankı istiyorum, ama ben farklı değerler alıyorum?
}
?>
</body>
</center>
</html>