0% found this document useful (0 votes)
2 views

Assignment+3+php

The document includes a series of PHP and HTML files created by Aditya Bansal for an assignment, featuring a widget order form, a conditional processing script, a registration form, and a reply page. The widget order form allows users to specify a quantity of widgets, calculates total cost with tax and potential discounts, and provides payment options. The registration form collects user information and displays a confirmation message upon submission.

Uploaded by

adityabansal522
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment+3+php

The document includes a series of PHP and HTML files created by Aditya Bansal for an assignment, featuring a widget order form, a conditional processing script, a registration form, and a reply page. The widget order form allows users to specify a quantity of widgets, calculates total cost with tax and potential discounts, and provides payment options. The registration form collects user information and displays a confirmation message upon submission.

Uploaded by

adityabansal522
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

{conditionalform.

html}

<!--
Student Name: Aditya Bansal
Student Id: 0825487
Class: MIT439_004
Assignment: 3
Date: 31 January 2024
URL: https://w24aer.scweb.ca/MIT439/week3/conditionalform.html
-->

<!DOCTYPE html>
<html>
<head>
<title>Html widget order form - by {Aditya Bansal}</title>
</head>
<body>
<h2>Widget Order Form</h2>
Our widgets cost $2,000.00 each.<br />
<form action="conditional.php" method="post">
How many widgets would you like to order:
<input type="text" name="quantity" size="4"><br /><br />
<input type="submit" name="submit" value="submit!">
<input type="reset" name="reset" value="reset!">
</form>
</body>
</html>

{conditionalform.php}

<!--
Student Name: Aditya Bansal
Student Id: 0825487
Class: MIT439_004
Assignment: 3
Date: 31 January 2024
URL: https://w24aer.scweb.ca/MIT439/week3/conditional.php
-->

<!DOCTYPE html>
<html>
<head>
<title>conditionals.php</title>
</head>
<body>
<?php

$quantity = $_POST['quantity'];
$cost = 2000.00;
$discount = 100.00;
$tax = 0.13;

// Check if quantity is not empty


if (!empty($quantity)) {
// Increment tax rate
$tax++;

// Calculate total cost without discount


$totalcost = $cost * $quantity;

// Check for discount eligibility


if (($totalcost < 5000) and ($discount)) {
echo ("Your \$$discount discount will not be applied!<br />");
}

// Apply discount if total cost is greater than or equal to 5000


if ($totalcost >= 5000) {
$totalcost = $totalcost - $discount;
}

// Calculate total cost with tax


$totalcost = $totalcost * $tax;

// Calculate monthly payments


$payments = round($totalcost, 2) / 12;

// Display information to the user


echo ("<h2>The payment calculation program</h2>");
echo ("<h2>programmed by {Aditya Bansal}</h2>");
echo ("You requested to purchase $quantity widget(s) at \$$cost each.<br />");
echo ("The total with tax, minus any discount, comes to $");
echo ($totalcost);
echo (".<br />You may purchase the widget(s) in 12 monthly installments of $");
echo ($payments);
echo (" each.<br />");
} else {
// Display error message if quantity is empty
echo ("Please make sure that you have entered a quantity and then resubmit.");
}
?>
</body>
</html>
{registerForm.php}

<!--
Student Name: Aditya Bansal
Student Id: 0825487
Class: MIT439_004
Assignment: 3
Date: 31 January 2024
URL: https://w24aer.scweb.ca/MIT439/week3/registerForm.php
-->

<!DOCTYPE html>
<html>
<head><title>Register Form</title></head>
<body>
<h2>Welcome to the ABC Web Site</h2>
<h3> - programmed by Aditya Bansal - </h3>
<form action="reply.php" method="post">
<p>
Enter your name: <input type="text" name="username"><br />
You live in: <input type="text" name="region"><br /><br />
<input type="submit" name="SUBMIT" value="Submit">&nbsp;&nbsp;&nbsp;
<input type="reset" name="RESET" value="Clear"></p>
</form>
<p><br /><em>
<?php
echo "Date: " . date('F dS, Y');
?>
</em></p>
</body>
</html>

{reply.php}

<!--
Student Name: Aditya Bansal
Student Id: 0825487
Class: MIT439_004
Assignment: 3
Date: 31 January 2024
URL: https://w24aer.scweb.ca/MIT439/week3/reply.php
-->
<!DOCTYPE html>
<html><head><title>Process Registration Form</title></head>
<body><h2>ABC Web Site Registration Reply Page</h2>
<?php
$username = $_POST['username'];
$region = $_POST['region'];
if (empty($username)) {
echo "You did not enter a username.<br />";
echo "Please return to the form and re-enter your information";
} else {
echo "<h3>Your information has been processed.</h3>";
echo "Thank you $username<br />";
echo "From the lovely region of : $region";}
?>
</body>
</html>

You might also like