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

This is the assignment I am working on. I am fine with all the HTML parts of thi

ID: 3804484 • Letter: T

Question

This is the assignment I am working on. I am fine with all the HTML parts of this assignment. However, I am having issues with Part 2, the PHP part. I would appreciate any help. Thank you very much.

COP2840 Assignment #7 Due at the start of class, Wednesday, March 22 1. Write an HTML document named light bulbs.html to create a form with the following capabilities. a. A text widget to collect the user's name b. Four checkboxes, one each for the following items i. A 25-watt light bulb for $2.39 ii. A 40-watt light bulb for $4.29 iii. A 60-watt long-life light bulb for $3.95 iv. A 100-watt long-life light bulb for $7.49 c. A collection of four radio buttons that are labeled as follows: i. Visa. ii. Master Card iii. Discover iv. Check 2. Write a PHP script named lightbulbs.php to handle the data from the form described in light bulbs.html that computes the cost of each product, e total number of items orde and the total cost of the order after adding 6.2 percent sales ta The name, unit, price, number ordered, and total cost for each product are presented to the client in a table defined with interwoven HTML markup and PHP script. Notice the table structure is described with the HTML, but the contents of some of the data cells are defined with PHP Important notes: 1. Total points: 10 2. Automatic 5 points deducted for files that do not work or produce incorrect outputs 3. Put your name in the source files as comment. 4. Two points will be deducted if the file does not have your name at the top in comments. 5. For submission, save the following source files i assignment7 folder: lightbulbs.html, light bulbs.php. Good luck.

Explanation / Answer

<html>
<body>
<form name="form_option" action="" method="POST">
Username: <input type="text" name="user">
<p>Option Check Boxes</p>
<input type="checkbox" name="option1" value="1">Four 25-watt light bulbs for $2.39<br>
<input type="checkbox" name="option1" value="2">Eight 25-watt light bulbs for $4.29<br>
<input type="checkbox" name="option1" value="3">Four 25-watt light bulbs for $3.95<br>
<input type="checkbox" name="option1" value="4">Eight 25-watt light bulbs for $7.49
<p>Option Radio Button</p>
<input type="radio" name="option2" value="Visa">Visa<br>
<input type="radio" name="option2" value="Master Card">Master Card<br>
<input type="radio" name="option2" value="Discover">Discover<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
// define variables and set to empty values
$name = $email = $gender = $comment = $website = ""; $count=0;

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = test_input($_POST["user"]);
$checkbox = test_input($_POST["option1"]);
$radio = test_input($_POST["option2"]);
$array[]=array(2.39,4.29,3.29,7.49);
if(empty($checkbox))
{
echo("You didn't select any thing.");
}
else
{
$N = count($checkbox);
for($i=0; $i < $N; $i++)
{
$count=$count+$array[$checkbox[$i]-1];
}
}
echo "Name".$name.",Cost:".$count.",Card:".$radio;
}

function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>

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