[ Team LiB ] Previous Section Next Section

Workshop

Quiz

1:

Which $_SERVER array element could you use to determine the IP address of a user?

2:

Which predefined variable could you use to find out about the browser that called your script?

3:

What should you name your form fields if you want to find an array in the element $_REQUEST['form_array']?

4:

Which superglobal associative array contains all values submitted as part of a GET request?

5:

Which superglobal associative array contains all values submitted as part of a POST request?

6:

What function would you use to redirect the browser to a new page? What string would you pass it?

7:

How can you limit the size of a file that a user can submit via a particular upload form?

8:

How can you set a limit on the size of upload files for all forms and scripts?


Answers

A1:

The $_SERVER['REMOTE_ADDR'] element should store the user's IP address.

A2:

Browser type and version, as well as the user's operating system, are usually stored in an element called 'HTTP_USER_AGENT' in the $_SERVER array.

A3:

Creating multiple fields with the name form_array[] creates a populated array in $_REQUEST['form_array'] when the form is submitted.

A4:

The superglobal array $ GET contains all values submitted as part of a GET request.

A5:

The superglobal array $_POST contains all values submitted as part of a POST request.

A6:

You can redirect a user by calling the header() function. You should pass it a Location header:

header("Location: anotherpage.html");

A7:

When creating upload forms in PHP, you can include a hidden field called MAX_FILE_SIZE:

<input type="hidden" name="MAX_FILE_SIZE" value="51200" />

A8:

The php.ini option upload_max_filesize determines the maximum size of an upload file that any script will accept. It is set to 2MB by default.


    [ Team LiB ] Previous Section Next Section