Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 2 Form Validation and PHP introduction Name Type Control Type Requirement FirstName String TextBox 50 Characters max. First letter must be capitalized. LastName String

Assignment 2

Form Validation and PHP introduction

Name

Type

Control Type

Requirement

FirstName

String

TextBox

50 Characters max. First letter must be capitalized.

LastName

String

TextBox

50 Characters max. First letter must be capitalized.

Age

Int

Shall be a valid integer. Value shall fall within range of 0 to 100.

Gender

String

Radio

50 Characters Max. First letter must be capitalized.

Male, Female, NA. Only one option can be selected at any given time.

Height

int

2 Textboxes. 1 for Feet, the other for Inches.

Shall be a valid double (decimal) number. Max height shall be 10 feet 0 inches.

Phone

phone

Textbox with the max length of 12.

Phone

Phone

Textbox with the max length of 12.

Must be a standard 9 digit US number with or without parentheses and dashes. Both cases should be valid. The user shall not be able to type more than 12 characters in the textbox. (123) 456 7890, 123-456-7890 should both be valid.

Address

String

Textbox

Max Length 250 characters.

City

String

Textbox

Max Length 75 Characters.

State

String

Select Option

Select box with all 50 states in Abbreviated form displayed and capture the actual state as the value.

ZipCode

String

TextBox

Must be a valid Zip Code. 5 digits or 5 and 4 digits separated by a hyphen. 12345 or 12345-6789 should both be valid. The textbox shall have a size of 10 and not allow the user to enter more than 10 characters.

FavoriteColor

String

A range of 10 valid HTML colors in a select option control

The Display should show the color and name of the color. The value should be the valid HTML color. Named color or HEX values can be used.

AboutMe

String

TextArea

A textbox with no size limit.

SubmitButton

Form action

Submit

Invoke the submit action.

FavoriteNumber

Int

TextBox

An integer

  1. All form values must be validated to meet the required specifications upon clicking the submit button.
  2. Errors in the form shall be displayed next to the form control that has the error.
  3. The form shall only be submitted when all values in the controls are validated to meet the specifications.
  4. The validation scripts must reside in a separate JavaScript file include through the header of the html document.
  5. The Form must be structured in a readable format.
  6. The method of the form shall be POST.
  7. The action of the form shall be processform.php.

Form Processing

This next portion of the assignment focuses on using PHP to process the form.

  • Create a file called processform.php.
  • Assign all $POST variables to the respective counterparts following the conventions indicated in the lecture slides. For example: $FirstName = $_POST[FirstName];
  • Validate that the values submitted are correct using simple if-then logic to meet the same criteria as indicated above.

There are more efficient methods that we will explore later, and you are welcome to use those so long as the data is validated.

  • After the form variables are validated, the resulting php page shall do the following:
  1. Have the same general layout as form page. Meaning the header, footer and layout should be consistent with the home page.
  2. Display the results of the form in a presentable manner, either in table structure, or you can get creative. As long as the proper data is displayed with the proper field names, I wont be picky. For example: Height should be as follows: Height: 510
  3. You can use a mix of HTML layout and PHP to display the data, it doesnt matter to me. For example, you can do something like this: First Name:.
  4. Data with Invalid values should be highlighted in Red.
  5. Calculate a magic number by doing the following:
  1. Take all the numeric values of the phone number and strip out the parentheses and dashes as your first number. For example 123-456-789 will be 123456789
  2. Take all the numeric values of the Zipcode and strip out the dashes to form your second number. For example 12345-6789 will be 123456789
  3. The third number will be decimal equivalent in feet of the height. So 5 feet 10 inches will be equivalent to 5.83.
  4. The fourth number will be the age.
  5. Take the first and second number and add them to get the Quotient.
  6. Take the third and fourth number and add them to get the dividend.
  7. Finally divide the Quotient by the dividend. This is your Magic Number.
  1. Display your magic number as part of the output. With the text Your Magic Number is: $MagicNumber.

Ensure the processform.php works as expected and the results are displayed properly.

Show an Error message in Red if validation fails, otherwise show a success message in Green.

Provide a link to route back to the original form if validation fails.

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

6. Have you used solid reasoning in your argument?

Answered: 1 week ago