html/php
1. Create an html page (with an html file ending) that contains a form. This form will accept a number from the user. The form will then send this number to the assignment3.php program by using either GET or POST.
2. The assignment3.php program will read the value in the textbox and place it into the variable "myvalue". The program will then use either a switch statement or IF/THEN/ELSE statement to determine if the value entered is within 10 (below or above) the number 25. If it is, the message "You are good at guessing" will be displayed. If it is more than 10 (above or below) the message "You missed it, but please try again" will be displayed.
3. If the user guess 25 exactly, the program will use a loop (your choice of the type of loop) to display "You won!!" 25 times on the web page.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
This demonstration is using WAMP Server.
Here a new web page with name "assignment3.html" is created, which contains following code.
assignment3.html :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- title for web page -->
<title>assignment3</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<form action="assignment3.php" method="post">
Enter Number :
<input type="text" name="number"/>
<br><br>
<input type="submit" name="btnSubmit"/>
</form>
</body>
</html>
*******************************
assignment3.php
<?php
if(isset($_POST['btnSubmit']))
{
//number entered by user
$myvalue=$_POST['number'];
//checking $myvalue
if($myvalue <=10)
{
//display message
echo "You are good at guessing<br/>";
}
else if($myvalue==25)
{
//if $myvalue is exactly 25 then
//using for loop display
for($i=0;$i<25;$i++)
{
echo "You won!!<br/>";//print message
}
}
else if($myvalue >10)
{
//if $myvalue is greater than 10
//display message
echo "You missed it, but please try again<br/>";
}
}
?>
======================================================
Output : Open web page assignment3.html in the browser and will get the screen as shown below
Screen 1 :assignment3.html
Screen 2 :Screen when number is below 10
Screen 3 :Screen when number is equal to 25
Screen 4 :Screen when number is above 10
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Get Answers For Free
Most questions answered within 1 hours.