diff --git a/README-template.md b/README-template.md deleted file mode 100644 index cb67027..0000000 --- a/README-template.md +++ /dev/null @@ -1,53 +0,0 @@ -# PHP-Task - *Name of App Here* - -**Name of your app** is a tip calculator PHP page. - -Submitted by: **Your Name Here** - -Time spent: **X** hours spent in total - -## User Stories - -The following **required** functionality is complete: -* [ ] User can enter a bill amount, choose a tip percentage, and submit the form to see the tip and total values. -* [ ] Tip percentage choices use a PHP loop to output three radio buttons. -* [ ] PHP code sets reasonable default values for the form. -* [ ] PHP code confirms the presence and correct format of submitted values. -* [ ] Page indicates any form errors which need to be fixed. -* [ ] Submitted form values are retained when errors or results are shown. - -The following **optional** features are implemented: -* [ ] Add support for custom tip percentage -* [ ] Add support for splitting the tip and total - -The following **additional** features are implemented: - -* [ ] List anything else that you can get done to improve the functionality! - -## Video Walkthrough - -Here's a walkthrough of implemented user stories: - -Video Walkthrough - -GIF created with [LiceCap](http://www.cockos.com/licecap/). - -## Notes - -Describe any challenges encountered while building the app. - -## License - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index 4d3722f..f09c336 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,36 @@ -# Tip Calculator in PHP +# PHP-Task - Tip Calculator PHP page -This pre-work incorporates the following 3 required steps and 3 optional steps: +Submitted by: Himanshu Sharma -1. Install PHP -2. Build a Tip Calculator using PHP -3. Submit your code for review -4. Optional: Add support for custom tip percentage -5. Optional: Add support for splitting the tip and total -6. Optional: Extend your app, improve UI, add features +Time spent: 4 hours spent in total +## User Stories ------ +The following **required** functionality is complete: +* [ * ] User can enter a bill amount, choose a tip percentage, and submit the form to see the tip and total values. +* [ * ] Tip percentage choices use a PHP loop to output three radio buttons. +* [ * ] PHP code sets reasonable default values for the form. +* [ * ] PHP code confirms the presence and correct format of submitted values. +* [ * ] Page indicates any form errors which need to be fixed. +* [ * ] Submitted form values are retained when errors or results are shown. +The following **optional** features are implemented: +* [ ] Add support for custom tip percentage +* [ ] Add support for splitting the tip and total -### 1. Install PHP +The following **additional** features are implemented: -Refer to the PHP.net website for general installation instructions. -http://php.net/manual/en/install.php +* [ ] List anything else that you can get done to improve the functionality! -* If you are on a Mac, PHP should already be installed. You can open up the Terminal application and type "php -v" to find out which version you have. PHP 5.5 or later is required for this course, and PHP 7 or later is preferred. If you want to upgrade to a newer version and do not already have experience with package managers like Homebrew, MacPorts, or Fink, then the installer by Liip will be the easiest way to upgrade. +## Video Walkthrough -* If you are on Windows, installing WAMP (http://www.wampserver.com/en/) which includes PHP, Apache, and MySQL may be easier than any of the other installation choices. (The assignment does not use Apache and MySQL, but the course will.) +Here's a walkthrough of implemented user stories: -### 2. Build a Tip Calculator using PHP +Video Walkthrough -* Build an HTML page which includes a form for calculating the amount of tip using the amount of the bill without tip and the tip percentage. - * The bill subtotal should be a text input to allow any value. - * The tip percentage should use radio buttons for three choices: 10%, 15%, and 20%. IMPORTANT: You MUST use a PHP loop to output the three radio buttons. +GIF created with [LiceCap](http://www.cockos.com/licecap/). -* Submitting the form will initiate form processing using PHP. It should: - * Set reasonable default values. - * Confirm the presence and format of submitted values. The bill subtotal should be present and greater than 0. The percentage should be present and greater than 0. - * If all values are valid, calculate the amount of the tip and the total bill when the tip is included. +## Notes -* After PHP processes the form, the form should be re-displayed with: - * Form fields pre-populated with the submitted values and selections. - * Indicate any form errors which need to be fixed. - * If all values were valid, display the amount of the tip and the total bill when the tip is included in a box below the form. Be sure to format the values properly as currency. This result box should not display the first time the page loads (only after a form is submitted). +The only part that was challenging was the error handling. -* Use CSS to add design to make your page look good. - - -**An example of the finished product with required features complete:** - -tip calcculator - required - -### 3. Submit your code for review - -Once you've completed the Tip Calculator application, please [push your app via Github](https://help.github.com/articles/create-a-repo). Also be sure to **include a README** containing a GIF walkthrough using [LiceCap](http://www.cockos.com/licecap/) of the app demonstrating how it works with required user stories completed. Use [this README template](https://raw.githubusercontent.com/ACM-SNU/php-task/master/README-template.md). - -After you have **completed all required user stories and added a README as described above** then you are ready to notify us that you are ready for a pre-work review. You can either mail us at acm@snu.edu.in or send a pull request to this repository. - -**Note:** All project code repos are pushed to github. If needed, review how to push your apps to github with [this handy tutorial](https://help.github.com/articles/create-a-repo). You should add a [.gitignore](https://raw.githubusercontent.com/github/gitignore/master/Objective-C.gitignore) to your project as well to **avoid storing compiled and local files in git**. - -### Submission Checklist - -Please **review the following checklist** to ensure your submission is valid: - 1. Did you successfully **push your code to github**? Can you see the code on GitHub? - 2. Did you **add a README** which includes a **GIF walkthrough** of the app's functionality? - 3. Did you **use our [README template](https://raw.githubusercontent.com/ACM-SNU/php-task/master/README-template.md)** for your README? - 4. Does your **GIF render directly in your README?** When using Imgur, you can right-click on the gif and choose "Copy Image Address" to get the correct address. Make sure the address has a `.gif` extension. If you end up with a url that has a `.gifv` extension, removing the `v` and changing this to `.gif` will ensure the gif renders on GitHub. - -Congratulations on completing the required portion of the pre-work! The remaining steps are optional, but **completing them will significantly improve your skills**. - -### 4. Optional: Add support for custom tip percentage - -* After the three percentage radio buttons, add a fourth radio button labeled "Custom". Include a text input to allow users to enter a custom tip percentage value (such as "18.5"). - -* In the PHP processing, use the custom tip percentage whenever "Custom" has been selected. Be sure to provide good default values and to correctly re-display all the submitted values when the result is shown. - - -### 5. Optional: Add support for splitting the tip and total - -* Add a new text input which will allow users to split the tip and total bill between any number of people. - -* The split number should default to 1 and should not work for 0 or negative numbers. - -* Display both the split tip and the split total. - - -### 6. Optional: Extend your app, improve UI, add features - -The sky's the limit on ways you can improve your code. Some ideas include: -* improve the design -* add JavaScript or Ajax (but not to replace the PHP) -* define custom functions to better organize the code -* enhance the error messages -* use locale specific currency -* add a currency thousands separator -* store the last submission in a cookie or the session - -## An example of the finished product with required features complete: - -tip calculator - optionals diff --git a/handler.php b/handler.php new file mode 100644 index 0000000..79b85a1 --- /dev/null +++ b/handler.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/img.gif b/img.gif new file mode 100644 index 0000000..14d8852 Binary files /dev/null and b/img.gif differ diff --git a/site.php b/site.php new file mode 100644 index 0000000..61edb48 --- /dev/null +++ b/site.php @@ -0,0 +1,30 @@ + + + + + + +
+ 0){ + // If tip is greater than 0, then only we should print our result else not. //?> + Tip: $".$tip."
Total: $".$total.""; + ?> + Either the tip is zero or the input is not valid."; + } + + ?> + +
+ + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..947fa51 --- /dev/null +++ b/style.css @@ -0,0 +1,23 @@ +pr { + color: red; +} + +parent { + color:red; + border-style: solid; + border-width: medium; +} + +div { + width: 300px; + border: 5px solid green; + padding: 25px; + margin: 25px; +} + +div1 { + width: 300px; + border: 5px solid black; + padding: 25px; + margin: 25px; +} \ No newline at end of file diff --git a/view.php b/view.php new file mode 100644 index 0000000..3f3379f --- /dev/null +++ b/view.php @@ -0,0 +1,45 @@ + + + TIP CALCULATOR + + + + + +
+ +

Tip Calculator

+ + +
+ BILL $:
+ + + +
+ Tip percentage:
+
+ + + > %; + + +
+ +
+ +
+
+ + +
+ + + + \ No newline at end of file