Edit the html code of the form to include placeholders


Chapter 12 - Error Handling and Validation

Instructions: Update the PHP file (i.e. ROakley_A4.php) so that it accomplishes all steps. Submit the PHP file and the 3

screenshots of the form in D2L in the Assignment 4 Dropbox. PHP section

1. Create the following variables to store error messages. Set all variables equal to an empty string. Set siteError equal to

(zero) 0.

Variable names

nameError

name

commentError

email

emailError

comment

statusError

status

siteError

2. Write PHP code that will check to see if the request method used is POST.

If that is true, then the user has submitted data that needs to be validated.

3. Write the PHP code to check the name field. If it is empty, set name variable to "Full Name is Required" & set siteError

variable to 1.

If the name field is not empty, set the name variable to the data the user entered then validate that it is in the proper format.

Set nameError variable to "Only letters and white spaces allowed" if it is not in the proper format.

(HINT: the data the user entered is store in $_POST["fieldname"] where fieldname is the field of interest.)

4. Write the PHP code to check the email field. If it is empty, set email variable to "Email is Required" & set siteError variable to 1.

If the email field is not empty, set the email variable to the data the user entered then validate that it is in the proper format.

Set emailError variable to "Invalid email format" if it is not in the proper format.

5. Write the PHP code to check the comment field. If the comment field is empty, set commentError variable to "Comment to

Advisor is Required" & set siteError variable to 1. If the comment field is not empty, set the comment variable to the data the

user entered.

6. Write the PHP code to check the status field. If the status field is empty, set statusError variable to "Academic Status is

Required" & set siteError variable to 1. If the status field is not empty, set the status variable to the data the user entered.

7. Write the PHP code to check if the siteError variable is not equal to 1 (which indicates there are no error messages present).

If this is true, display all the data that was received from the user, else display the following error message "There is an error!

Check your input."

HTML section

8. Edit the HTML code of the form to include placeholders which give the user prompts in the browser.

9. In the PHP sections within the HTML code, echo out the appropriate comment variables as indicated.

10. Test your code and take 3 screenshots of the form:

a. Before any data is submitted

Note that the user-entered data is bolded!!

b. When no data or incorrect data is entered

c. When correct data is entered Chapter 12 - Error Handling and Validation

Instructions: Update the PHP file (i.e. ROakley_A4.php) so that it accomplishes all steps. Submit the PHP file and the 3

screenshots of the form in D2L in the Assignment 4 Dropbox. PHP section

1. Create the following variables to store error messages. Set all variables equal to an empty string. Set siteError equal to

(zero) 0.

Variable names

nameError

name

commentError

email

emailError

comment

statusError

status

siteError

2. Write PHP code that will check to see if the request method used is POST. If that is true, then the user has submitted data

that needs to be validated.

3. Write the PHP code to check the name field. If it is empty, set name variable to "Full Name is Required" & set siteError

variable to 1. If the name field is not empty, set the name variable to the data the user entered then validate that it is in the

proper format. Set nameError variable to "Only letters and white spaces allowed" if it is not in the proper format.

(HINT: the data the user entered is store in $_POST["fieldname"] where fieldname is the field of interest.)

4. Write the PHP code to check the email field. If it is empty, set email variable to "Email is Required"

& set siteError variable to 1. If the email field is not empty, set the email variable to the data the user entered then validate

that it is in the proper format. Set emailError variable to "Invalid email format" if it is not in the proper format.

5. Write the PHP code to check the comment field. If the comment field is empty, set commentError variable to "Comment to

Advisor is Required" & set siteError variable to 1. If the comment field is not empty, set the comment variable to the data the

user entered.

6. Write the PHP code to check the status field. If the status field is empty, set statusError variable to "Academic Status is

Required" & set siteError variable to 1. If the status field is not empty, set the status variable to the data the user entered.

7. Write the PHP code to check if the siteError variable is not equal to 1 (which indicates there are no error messages present).

If this is true, display all the data that was received from the user, else display the following error message "There is an error!

Check your input."

HTML section

8. Edit the HTML code of the form to include placeholders which give the user prompts in the browser.

9. In the PHP sections within the HTML code, echo out the appropriate comment variables as indicated.

10. Test your code and take 3 screenshots of the form:

a. Before any data is submitted

Note that the user-entered data is bolded!!

b. When no data or incorrect data is entered

c. When correct data is entered

 

Solution Preview :

Prepared by a verified Expert
Visual Basic Programming: Edit the html code of the form to include placeholders
Reference No:- TGS01235972

Now Priced at $60 (50% Discount)

Recommended (90%)

Rated (4.3/5)

A

Anonymous user

2/10/2016 3:49:56 AM

For the given PHP problems, provide the codes and snapshots wherever required. Problem 1: Write down the PHP code which will check to see if the request method used is POST. If the above is true, then the user has submitted data that requires to be validated. Problem 2: Write down the PHP code to check the name field. If it is empty, set the name variable to "Full Name is required" & set siteError variable to 1. If the name field is not unfilled, put the name variable to the data the user entered then validate that it is in the correct format. Set nameError variable to ‘Only letters and white spaces allowed’ if it is not in the correct format.