Select Page

COMS 201 MSUM Synology NAS server PHPFormEx & PHP Response Programming Exercise

Question Description

I’m working on a programming project and need support to help me understand better.

Complete the following exercises and upload them on our Synology NAS server in a folder called PHPFormEx. Please place them at the root of your own folder. i.e. Nuria-Web/PHPFormEx/

Exercise 1: Simple Form with PHP Response

In this PHP exercise, you will request input from the user, then move the user’s response from one file to another and do something with it.

Create two separate PHP files. The first will contain a form with one input field asking for the user’s favorite city. This file should be named main.php. Use the post method for the form. Although this file contains no PHP code, on your Atom localhost, it needs the .php extension to successfully call the second file.

The second file, named response.php, will contain PHP code to process the user’s response. (In this case, something very simple.) After the user clicks the submit button, echo back Your favorite city is $city., where $city is the input from the form.

Hint: the variable that contains the user’s input is an array. Arrays will be addressed in future exercises, but this particular array needs to come into play here. The array variable is $_POST[‘name’], where ‘name’ is the name of your input field.

===================================

Exercise 2: Interactive Form with If-Else Statement

One very useful thing you can do with PHP is include the request for user input and the response in the same file, using conditional statements to tell PHP which one to show. For this PHP exercise, rewrite the two files of the previous exercise into one file using an if-else conditional statement. Name this single PHP file favoriteCity.php

Hint: You’ll need some way to tell if the form has been submitted. The function to determine if a variable has been set and is not null is isset().

====================================

Exercise 3: If-Elseif-Else Construction

For this PHP exercise, you will use the same format as the previous exercise, requesting input in the first part, and responding in the second, through the magic of PHP’s if-else statement. In the first section, give the user an input field and request that they enter a day of the week.
For the second section, you’ll need the following poem:

Laugh on Monday, laugh for danger.?
Laugh on Tuesday, kiss a stranger.?
Laugh on Wednesday, laugh for a letter.?
Laugh on Thursday, something better.?
Laugh on Friday, laugh for sorrow.?
Laugh on Saturday, joy tomorrow.

Using the else-elseif-else construction, set each line to output in response to the day the user inputs, with a general response for any input that is not in the poem.

Name the PHP file daysOfPoem.php

====================================

Exercise 4: Switch Statement

You probably noticed that the if-elseif-else construction was repetitive and cumbersome in the last exercise. It works best with only one or two choices. A more appropriate construction for this exercise is the switch statement, combined with a select field in the form for the days of the week. So your assignment in this PHP exercise is to rewrite the previous exercise using a select field for the user input and the switch statement to process the response.

Once again, here’s the poem:
Laugh on Monday, laugh for danger.?
Laugh on Tuesday, kiss a stranger.?
Laugh on Wednesday, laugh for a letter.?
Laugh on Thursday, something better.?
Laugh on Friday, laugh for sorrow.?
Laugh on Saturday, joy tomorrow.

Remember to include a general response for any input that is not in the poem. To make things a little more interesting, include a ‘Back’ button on the response so that the user can go back and try different days.

Name the PHP file daysOfPoemSwitch.php

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."

Order Solution Now