- Predefined Variables
- A Script to Acquire User Input
- Accessing Form Input with User Defined Arrays
- Accessing Form Input with Built-In Arrays
- Distinguishing Between GET and POST Transactions
- Combining HTML and PHP Code on a Single Page
- Using Hidden Fields to Save State
- Redirecting the User
- File Upload Forms and Scripts
Which predefined variable could you use to determine the IP address of a user?
Which predefined variable could you use to find out about the browser that called your script?
What should you name your form fields to access their submitted values from an array variable called $form_array?
Which built-in associative array contains all values submitted as part of a GET request?
Which built-in associative array contains all values submitted as part of a POST request?
What function would you use to redirect the browser to a new page? What string would you pass it?
How can you limit the size of a file that a user can submit via a particular upload form?
How can you set a limit to the size of upload files for all forms and scripts?
The variable $REMOTE_ADDR should store the user's IP address.
Browser type and version, as well as the user's operating system, are usually stored in a variable called $HTTP_USER_AGENT.
Creating multiple fields with the name form_array creates a populated array called $form_array when the form is submitted.
The built-in array $HTTP_GET_VARS contains all values submitted as part of a GET request.
The built-in array $HTTP_POST_VARS contains all values submitted as part of a POST request.
You can redirect a user by calling the header() function. You should pass it a Location header:
When creating upload forms in PHP 4, you can include a hidden field called MAX_FILE_SIZE:
The php.ini option upload_max_filesize determines the maximum size of an upload file that any script will accept. This is set to 2 megabytes by default.
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="51200">
Create a calculator script that allows the user to submit two numbers and choose an operation to perform on them (addition, multiplication, division, subtraction).
Use hidden fields with the script you created in activity 1 to store and display the number of requests that the user has submitted.