Web Design Fall 2008
Scripts
What is PHP PHP stands for Hypertext Preprocessor. It is a coding language that allows a web designer to specify particular actions to be preformed on the server prior to sending a requested page over the internet to an end user. PHP outputs the final code in HTML format for the viewer to see. This means that any page can be converted to a PHP page by simply changing the file extension on that page to .php in stead of .html. PHP has unlimited uses including:
How to implement PHP PHP, as state above is a server side scripting language. A server knows that a file should be checked for php code by the file extension. So to implement a php script the first step is to make sure the file extension is set to .php. Once a file has the extension .php on it the server will know to check that document for php scripts to execute before sending the page to a viewer. The code that defines the start of php scripts to be run on a server is <? and the inverse of this is used to define the end of a php script ?>. These opening and closing statements can be put into your .php document anywhere where you want to have a php script. However, anything inside of the <? ?> will be executed as php and therefore must be in php format to avoid error messages. PHP Demonstrations Showing the current date: this demonstration will show the current date on a webpage
Using the include function: this demonstration will show you how to use the include function to combine 2 pages in html format into 1 for the user to see.
This function is very useful for the navigation area of your website. This is especially true if you anticipate the need to ad additional pages later on. If you place this script on each on of your pages in place of your navigation buttons, and links you can then modify the navigation element across your entire site by simply modifying the nav.html file which is where you put all your buttons and links. Using PHP for user submitted forms A form on a website consists of 2 parts. First is the form its self which the user will fill out and then click a submit button. The second part is a php script that gathers the data the user has submitted and then performs an action with that data such as e-mailing it back to the server admin. Feedback form and submit button: This link is to a php file within a zip file that contains all the scripting necessary to have a feedback form on a website. This is the most simple execution of this functionality and doesn't include any safeguards or required fields. This file is commented to explain the different actions being preformed |