Lesson 02 - Your first Request Info form
Download this file: Lesson02_FirstForm.txt to your PC. Change the extension to .php. Change the recipient address and then upload to your website. Surf to the Lesson02_FirstForm.php file on your website with your browser. You should see results similar to the image above on the right. After completing the form and clicking Send me more info, you should receive an email with this in the body:
GotchasI used to have the words below, but then my ISP upgraded and used the default istallation for PHP. So the source code is indicative of register_globals = off. (Old words: If you did not receive an email or if the contents were blank, then perhaps this is true: In PHP 4.2.0 and later, the default value for the PHP directive register_globals is off. This is a major change in PHP. Having register_globals off affects the set of predefined variables available in the global scope. You need to run the phpinfo() function on your website and check that register_globals is set to "on".) If your version of PHP is below 4.3.x, then call your hosting company. They need to upgrade to a newer version of PHP. Source CodeThe code: What we do know is that all the typed in values are available in a predefined variable: $_POST. Therefore, we can get the value of the HTML name contactName from $_POST['contactName']. Note, that with register_globals turned on, $contactName and $_POST['contactName'] have the same value. The hidden variable $firstPass and the associated if() test are here so that the page will not send an email the first time it is loaded. The email is only sent when the submit button is clicked. If PHP is installed on your webserver, then download this file: Lesson02_FirstForm.txt to your PC. Change the file extension to .phps and upload the file to your webserver. View the file with your browser and you should see code identical to that shown below.
Final ThoughtsIf all went well, then you have learned three things:
|