Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Basic PHP commands question: Create a PHP file called action.php. This will be the file that will receive and process the results and generate the

Basic PHP commands question:

Create a PHP file called action.php. This will be the file that will receive and process the results and generate the appropriate content. Here's the html code for user's input. Feel free to edit if needed.

First Name: Unique Key:

Please add the following method in the php file. Thank you.

- In order to receive data from a request, you will need to use the appropriate superglobal variable. You will need to use the $_GET, $_POST and $_SERVER variables (as appropriate). Data sent to the server in this fashion is accessed using the field name as the key. To test your initial file, have your file echo out the contents of the firstname and key. Test your files to ensure data is being transmitted correctly.

-One of the conditions that needs to be handled

The case where no data is transmitted to a page when it is expecting data. In your PHP file, if you try to print out data for a variable that does not exist, it will generate an error. Modify your code so that it will only print out the values for firstname and key if the values are set.

- Data can be sent either with a POST or a GET. Modify your PHP file to be able to handle the data being sent with either method. You will be able to determine this using the $_SERVER superglobal. Test to ensure that it will be able handle both a POST and GET from your form (by changing the form method).

- Store the firstname and key in variables so that you are able to use them in your code to generate dynamic content. A text file called data.txt contains key, firstname, for two users. Modify your PHP code so that the file is read into memory using in-memory file access.

content in txt:

0101,Bob 0102,Sally

- Modify your PHP code such that it will display the users name, along with the values. If the user and/or key is invalid or not provided, display a message indicating that. You will need to examine how to compare strings with PHP (Hint: you cant just use the == operator). You will have to search for an appropriate PHP method that can handle this in a case-insensitive fashion).

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Determine the amplitude and period of each function.

Answered: 1 week ago