Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP choose the side a die has?
    primarykey
    data
    text
    <p>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.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8" /&gt; &lt;title&gt; choose a die number &lt;/title&gt; &lt;/head&gt; &lt;center&gt; &lt;body&gt; &lt;h1&gt;Choose a die number&lt;/h1&gt; &lt;form method = "post" action="choosedie.php"/&gt; &lt;!--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--&gt; Please choose how many sides a die should have from 1 through 6: &lt;br/&gt; &lt;input type = "text" name = "roll"/&gt; &lt;?php //Roll a random dice from 1 through 6: $roll = rand(1,6); // Add random variable to do comparison on. </code></pre> <p>Is there a way for me to just compare rand here, without having to create another variable?</p> <pre><code>$random = rand(1,6); // If $roll is equal to $random echo the output out to the user. If ($roll == $random) { echo "&lt;br/&gt;Here is the random $roll with the appropriate maximum value $random\n"; </code></pre> <p>If the user selects 5, I want this to echo out 5, but I am getting different values?</p> <pre><code>} ?&gt; &lt;/body&gt; &lt;/center&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload