Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1: Creating a Form (roughly 30 - 45 minutes) This exercise involves creating an HTML form that POSTs its submitted data to a PHP

Exercise 1: Creating a Form (roughly 30 - 45 minutes) This exercise involves creating an HTML form that POSTs its submitted data to a PHP program on a server. Download buyagrade.html to your disk (right-click the link and choose Save Link As...). You need to modify this HTML file by turning it into an HTML form. You will need to give name attributes to the form controls so they will be sent to the server as query parameters; the names are up to you. Also, some form controls (such as radio buttons) need value attributes. Fill the Section drop-down list with choices MA through MH. When you're done with this exercise, your form should look roughly like the screenshot at the top of this handout.

Test your form to see that it is submitting the proper parameters by temporarily setting its action attribute to: http://codd.cs.gsu.edu/~username/filename.php

buyagrade.html file:

Buy Your Way to a Better Education up in Here!

Buy Your Way to a Better Education up in Here!

Life itself is your professor, and you are in a state of constant learning, now there are 3 kinds of people in the world: people that can count and people that can't count. Which of the three are you?. That's right! All you need to get a 4.0 in this course. My education is about learning what you didn't know even if know you that didn't know.

'Do you need homework today I think so however the moment I forget to assign you homework there will be a scholar student to utter loudly 'We have homework...'


Give Us Your Money

Name
???
Section
???
Credit Card
???
I am a giant sucker.

buyagrade.css file:

html { background-color: #39275B; } body { width: 600px; margin: 1em auto; background-color: white; border: 10px #D8C858 solid; padding: 0.5em; } hr { width: 90%; border: 1px solid #D8C858; } h1, h2 { font-family: sans-serif; text-align: center; } input[type="submit"] { font-size: 2em; width: 100%; }

Exercise 2: Displaying Input Data (roughly 30-45 minutes) In this exercise, you will write the PHP page that will handle the submitted form data. Tell you buyagrade.html to POST to sucker.php. The sucker.php page will receive the parameters from buyagrade.html and will output an HTML confirmation page. Here is a sample version of how the page should be designed and work once the data is submitted by the user. sucker page Modify it to display the submitted data accordinaly. sucker.php Your page should at least display the submitter's name, credit card number, and credit card type (Visa or MasterCard) in the confirmation page. For now, your page doesn't actually need to save this information in any way on the server.

To keep your code clean, as much as possible you should embed variables' values in HTML using PHP expression blocks such as .

Exercise 3: Save the Form Data (roughly 30 - 45 minutes)

Modify your sucker.php page to save the submitted data to the file suckers.html. This file should have a format similar to the following (you can use the php cancat method):

 Tiger Woods;MA;1234123412341234;visa Hulk Hogan;MF;5963109385987345;mastercard Matt Ryan;MC;7328904328904902;mastercard Louis Henry;MC;4444100020003000;visa

Also change your page's output to show the complete contents of this file to the user. Place the file contents into an HTML

 element to preserve the whitespace.

Good Reference if needed you can read and write the contents of a file using the PHP file_get_contents and file_put_contents functions.

Exercise 4: Basic Data Validation (roughly 30-45 minutes) - you may encounter some permission issues notifiy us if you do -

Update your sucker.php file to verify that the user did not leave any fields blank when submitting the form. You can check whether a particular parameter has been passed using the PHP function isset.

However, isset($_REQUEST["name"]) will only check if the $_REQUEST associative array has "name" as one of its keys; it does not check to see if the value of $_REQUEST["name"] is a non-empty value. Remember that $_REQUEST["name"] = "" would give a falsey value and $_REQUEST["name"] = "abc" would give a truthy value.

If the user has not filled in every field, show an error message like the one below instead of displaying their submitted data:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting The Easy Way

Authors: Peter J. Eisen

3rd Edition

0812094093, 9780812094091

Students also viewed these Databases questions

Question

What is the maximum for SALE_PRICE?

Answered: 1 week ago