LAB GOALS Use PHP you learnt in class (including previous classes) to make a Lot
ID: 3885892 • Letter: L
Question
LAB GOALS Use PHP you learnt in class (including previous classes) to make a Lottery Page http://my.up.ist.psu.edu/jxw394/lottery.php Game rules: Generate a random integer $x in [1,3] as the lucky number Generate a random integer $y in [l,3] as your numbei If $y is the same as $x, print "you win the same" $y times in different headings; otherwise, print "you lose the game" $y times in different headings See next two slides for specitications If you meet every checkpoint in requirements, please submit your URL to Canvas under Lab3Explanation / Answer
index.html
<html>
<head>
<title>Number Lottery</title>
</head>
<body>
<?php
$no= $_POST['inputUser'];
$subBtn= $_POST['submit'];
$randNum= mt_rand(1,3);
?>
<form action="" method="POST">
Guess a Number Between 1 and 3:
<input type="text" name="inputUser" value=''/> <br><br>
<?php
if ($subBtn){
if (($no > 0) && ($no <11)){
if ($no != $randNum)
{
echo "Incorrect guess. The correct no was $randNum. Try again";
}
else
{
echo "$randNum is the correct guess. You got it right.";
}
}
}
?>
<br><br>
<input type="submit" name="submit" value="Search"/><br><br>
</form>
</body>
</html>
Rate an upvote.....Thankyou
Hope this helps.....
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.