IT-€230 Web Technologies Assignment 4 Due Date
IT-â€230 Web Technologies Assignment #4 Due Date
The assignment involves creating an order form in order.php that collects customer details and item selections, and a bill.php page that processes the order, calculates totals and discounts, and displays the order summary with proper currency formatting.
Paper For Above instruction
In the modern digital economy, the effective handling of web-based transactions is vital for both businesses and consumers. This paper explores the process of designing and implementing an online ordering system using PHP, focusing on form data collection, server-side processing, and currency formatting. The scenario involves two key components: an order form and a bill processing script, which together facilitate a seamless online purchase experience.
Designing the Order Form: order.php
The order.php page serves as the front-end interface for customers to input their personal and purchase details. It incorporates a comprehensive form that captures essential information: the customer’s name, address, three items with names and prices, and a discount selection. The form utilizes various HTML form elements including input fields, textarea, and a select dropdown to improve usability and data collection accuracy.
Specifically, the form collects:
- Name: a text input for the customer's name.
- Address: a textarea allowing the customer to enter their address.
- Items: three items, each with a name and price input. The pricing inputs are of type text but should be validated to accept numeric values.
- Discount: a select menu with options 5%, 10%, and 15%, stored as integer values 5, 10, and 15 respectively for calculation.
- Submit Button: labeled “Place Order”, which sends the form data via POST method to
bill.php.
Processing the Order: bill.php
Upon form submission, bill.php handles the processing, performing several critical operations:
- Data Retrieval & Sanitization: Securely accessing the submitted data, stripping HTML tags from name and address, and validating numeric values for item prices.
- Calculation of Totals:
- Total Price: sum of all three item prices.
- Discount Calculation: convert discount percentage to decimal (e.g., 10/100), compute discount amount, and apply it to total.
- Total Bill: final amount after discount.
- Formatting Monetary Values: all currency amounts displayed in SAR, with the currency symbol and two decimal places, e.g., SAR 84.47.
- Displaying the Order Summary: including sanitized customer name, plain address, list of items with names and prices, total amount, discount details, and final bill total.
The output structure will resemble areceipt with clear labels and formatted currency, following the provided example, ensuring clarity and professionalism in presentation.
Conclusion
This approach demonstrates fundamental web development skills involving form creation, server-side scripting, data validation and sanitization, calculations, and output formatting. Proper handling of monetary values, especially considering regional currency conventions, enhances user trust and provides a professional appearance. This example also emphasizes the importance of user data validation and security best practices in online transactions.
References
- PHP Manual. (2023). Handling Forms. Retrieved from https://www.php.net/manual/en/tutorial.forms.php
- W3Schools. (2023). PHP Form Handling. Retrieved from https://www.w3schools.com/php/php_forms.asp
- W3Schools. (2023). PHP String Functions. Retrieved from https://www.w3schools.com/php/php_ref_string.asp
- PHP Manual. (2023). String and Number Formatting. Retrieved from https://www.php.net/manual/en/ref.sprintf.php
- International Organization for Standardization. (2021). ISO 4217 Currency Codes. Retrieved from https://www.iso.org/iso-4217-currency-codes.html
- MDN Web Docs. (2023). Form Validation. Retrieved from https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Form_validation
- PHP Manual. (2023). Filter Functions. Retrieved from https://www.php.net/manual/en/filter.filters.php
- Stack Overflow. (2022). PHP Currency Formatting. Retrieved from https://stackoverflow.com/questions/14524846/php-currency-formatting
- OECD. (2020). Best Practices for E-commerce. Retrieved from https://www.oecd.org/sti/ieconomy/
- Region-specific currency information. (2023). Saudi Riyal (SAR). Retrieved from https://currencylayer.com/saudi-riyal