project folder needs to contain 2 files. You\'ll have a HTML page with a form th
ID: 3889379 • Letter: P
Question
project folder needs to contain 2 files. You'll have a HTML page with a form that submits 3 numbers to a web server. A PHP page on that web server will add the numbers, divide by 3, then return the average of the numbers to the user.
The first file is a regular HTML page with a HTML form. The form needs 3 named text-boxes, a submit button, and a reset button. It should look something like this:
The exact format is not that important, but you need these form element at a minimum. Also, we will assume the user actually enters numbers in the boxes and do not at this point need to validate the data.
Your second file is a PHP page that will take the 3 numbers, add them together, then send the original 3 numbers and the average of the numbers back to the user along with a little text explaining what is what. The output to your user can be set up any way you want, but there should be a sentence that looks very much like this on the return trip.
for example
The average of 4, 5, and 6 is 5.
Program to Return the Average of 3 numbers Enter 1st number. Enter 2ed number. Enter 3rd number Submit ResetExplanation / Answer
HTML page:
<html>
<body>
<form action="myPhpScript.php" method="post">
<p>Enter 1st number:</p>
<input type="number" name="n1"><br>
<p>Enter 12nd number:</p>
<input type="number" name="n2"><br>
<p>Enter 3rd number:</p>
<input type="number" name="n3"><br>
<button type="submit">Submit</button>
<button>Reset</button>
</form>
</body>
</html>
myPhpScript.php:
<html>
<body>
<?php
$x1 = $_POST["n1"];
$x2 = $_POST["n2"];
$x3 = $_POST["n3"];
$sum = (int)$x1 + (int)$x2 +(int)$x3;
$avg = $sum/3;
echo 'The sum of '.$x1.', '.$x2.', and '.$x3.' is: '.$sum.'</br>';
echo 'The average of '.$x1.', '.$x2.', and '.$x3.' is: '.$avg.'</br>';
?><br>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.