Corey Peoples 4/13/06 Lecture Presentation Coms 463 PHP, originally called Personal Home Page, is now a widely-used, server-side, general-purpose scripting language that is especially suited for Web development and can be embedded into HTML o Server side means that all pages are compiled on the server before the information is sent to the client computer Pros of PHP o Open source, Linux-based, many built-in functions and extensions, understand/debug, object support, variable-type variables Cons of PHP o Text-only interface, no warning errors until page is called, variable-type variables Code structure o <?php & ?> o Ends with ; o If/for/while with () o $variable o $_ for GET/POST/SESSION/SERVER/COOKIE o Includes, not imports Input/output o Forms pass to $_GET or $_PUT arrays o print_r() and echo for outputs to screen o fopen(“filename”, “r” | “w”) for read/write files Connect to mysql database o $conn = mysql_connect(“serverAddress”, “username”, “password”) to connect to the database, $conn is a resource link for some mysql commands o mysql_select_db(“databaseName”) is similar to mysql’s “USE databaseName” o $result = mysql_query(“Some SQL Query”) to retrieve the result set o $row=mysql_fetch_array($result) to retrieve a row, as an array, in the result set Mail function o SMTP server is specified in the php.ini file on the server o mail($to, $subject, $body, $header) Using includes for headers and footers o Keeps themes together for all pages o Header file should keep all code up to what you want to change on each page o The page should include the header, continue on from the header’s code, and include the footer. o Footer code should end all of the header’s tags o Non-visual forms do not need header/footer tags because they display nothing, they are only code executed on the server Professional pages o LAN-Fraggers uses PostNuke Content Management System o Vbulliten is a powerful and popular bulletin board system o Phpbb is a popular bulletin board that created bbcode Personal pages completed o Parkside realty – built with access to a large MySQL database, displays listings for properties in and around Owatonna, MN. Functions include: Uploading new listings in the form of a text file Uploading images for the properties Viewing images in a photo gallery Image resize Listing searches Add/edit/delete users Database error alerts o The Peoples Computer Repair – Built quickly to include a design template with PHP for working with clients. Functions include: Invoice preparation Accounting reports User logins o Central States Fire Investigations – Based out of Owatonna, this website was an upgrade to a CMS (Content Management System) for the ability to change the information on the website at his leisure. Functions include: User logins (only upon request) Invoice preparation Simple modification of information on all pages Personal Pages working on o Peoples Bead dreams to upload images in a CMS Environment o Mission Construction to upload image galleries o Shultz Homes to give estimates on new constructions o MA Graphics Design to give users access to their images, but not other people’s Short-answer questions 1. What was PHP’s original name back when it was first released? 2. Does PHP, a scripting language, support objects? 3. How does PHP allow input from forms? 4. What programming language is PHP based off of? 5. Can you import system API commands? Multiple Choice 1. PHP connects with what database(s)? a. MySQL b. SQL Server c. Oracle d. PostgreSQL e. All of the above 2. The Mail function takes in how many arguments a. Exactly 3 b. Exactly 4 c. Up to 4 d. At least 3 e. At most 3 3. What is PHP a. An open source scripting language b. Proprietary software c. A web site design program d. A database management system 4. Are PHP functions designed to work with images? a. to upload to servers b. to resize c. to display to the screen d. a and b, c is HTML based e. none of the above 5. What are the websites that commonly use PHP? a. Content Management systems b. Database access websites c. Online communities d. Personal pages Fill-in the blanks 1. The mail()’s SMTP server is specified by default by the _____________ 2. PHP pages on the server that do not display any HTML will ________ to other pages 3. When using forms, you should specify method=“_____________” to protect privacy 4. The function to open files for read/write is __________________, and takes 2 arguments 5. the PHP tags can be embedded anywhere in the _______ code, not just the header Short-answer questions 6. What was PHP’s original name back when it was first released? Personal Home Page 7. Does PHP, a scripting language, support objects? Yes 8. How does PHP allow input from forms? In $_GET or $_POST variables 9. What programming language is PHP based off of? Pearl 10. Can you import system API commands? No, PHP does not have API support, or imports Multiple Choice 6. PHP connects with what database(s)? a. MySQL b. SQL Server c. Oracle d. PostgreSQL e. All of the above 7. The Mail function takes in how many arguments a. Exactly 3 b. Exactly 4 c. Up to 4 d. At least 3 e. At most 3 8. What is PHP a. An open source scripting language b. Proprietary software c. A web site design program d. A database management system 9. Are PHP functions designed to work with images? a. to upload to servers b. to resize c. to display to the screen d. a and b, c is HTML based e. none of the above 10. What are the websites that commonly use PHP? a. Content Management systems b. Database access websites c. Online communities d. Personal pages Fill-in the blanks 6. The mail()’s SMTP server is specified by default by the PHP.INI file 7. PHP pages on the server that do not display any HTML will Redirect to other pages 8. When using forms, you should specify method=“$_POST” to protect privacy 9. The function to open files for read/write is fopen(), and takes 2 arguments 10. the PHP tags can be embedded anywhere in the HTML or Web Page code, not just the header