Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program with an HTML file and a PHP file. The files are called customdic

ID: 3620748 • Letter: W

Question

Write a program with an HTML file and a PHP file. The files are called customdice.html and customdice.php. The customdice.html should contain a form that allows the user to enter their name and the number of sides for their dice (do not worry with graphical dice, just output the values). Your customdice.php should take those values and output the persons name and 10 random rolls of their dice. Your PHP should also check the validity of the users input and if the number of sides is less than 0, then your PHP should generate a screen that says they inputted a negative value and that they should click the back button to make another entry.

Explanation / Answer

<html>
<body>
<br><br>
<br>
<form method = "post" action = "cust.php">
<table border="0">
<tr><td>
Name</td>
<td><input type="text" name = "nam"></td></tr>
<tr><td>

Sides</td>
<td><input type = "text" name = "sides"></td>
</tr>
</table>
<br><br>
<input type = "submit" value = "Submit">
<br><br>
</form>
</body>
</html>

<?php
        $s = (int)$_POST["sides"];

echo "<br><br>Your name is : " . $_POST["nam"];

if ( $s > 0)
        {
  echo "<br><br>Number of sides are : " . $_POST["sides"] . "<br><br>";

  $i = 0;
  for (; $i < 10; $i = $i + 1)
  {
   $j = 0;
  for (; $j < $s; $j = $j + 1)
       echo rand()%$s ." ";
     echo "<br>";
  }
}         
        else
        {
      echo "<br/>" . "Not a Valid number";
      echo "<br/>" . "<br/>" . "Click <a href="."cust.htm"."> here </a> to enter name and size";
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote