Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP, Databases, and Cookies Dave Pease IDS496 12/2/2003 www.dpease.com/php.

Similar presentations


Presentation on theme: "PHP, Databases, and Cookies Dave Pease IDS496 12/2/2003 www.dpease.com/php."— Presentation transcript:

1 PHP, Databases, and Cookies Dave Pease IDS496 12/2/2003 www.dpease.com/php

2 PHP Basics  Scripting language Non-compiled Similar in operation to Perl Similar in syntax to C Designed for the Web Releases exist for all major operating systems and HTTP servers  MS Windows/MS IIS, Linux/Apache, etc.

3 PHP Syntax  Server executes anything between as PHP code  # or // for comments  Lines end in semi-colons;  Generally all files with.php extensions are executed Can be changed in HTTP server configurations

4 PHP and HTML  PHP can be embedded in HTML Anything outside is ignored by PHP but rendered by HTTP server as normal

5 Passing Arguments to PHP  PHP can read command line arguments No argumentarg=foo

6 PHP and Forms  PHP can read data from HTML forms Check functions can be easily implemented Select boxes in forms can be populated in loops in PHP HTML page content always displays Utilize PHP’s helpful environmental variables

7 Databases and PHP  For content-heavy (article based) websites, PHP with a database back-end is an excellent solution Very few scripts and pages to maintain Easy to change features/colors/layout across entire site quickly Database (many articles) Single PHP pageSite visitor

8 Database types  MySQL Popular, many users, lots of documentation, excellent integration with PHP MyPHPAdmin is a popular, free tool that allows you to administer your MySQL database via the web  PostgreSQL Newer, more features, smaller user base  Both databases: Are free Support SQL instruction set (IDS 480)

9 Cookies  Information a website can write to a client Client must have cookies enabled in their browser Many legitimate uses  A site can only read a cookie that it put on the client’s computer, so allowing cookies won’t throw your entire hard drive open to unscrupulous websites to invade PHP has built-in support for cookies

10 Cookie Example: sessiontoken  When a user visits a site, PHP script checks for cookie If it exists, get unique sessiontoken from cookie to check login status in database If it doesn’t exist, create cookie with new sessiontoken and create new row in database Script “included” in every PHP page in site  Regular visitors/site members stay “logged in” and don’t have to re-enter their passwords

11 Resources  php.net Every PHP function documented  experts-exchange.com Good place to get answers to tough PHP/database questions  google.com Describe what you are trying to do and include the string “PHP” and you will nearly always find the answer documented somewhere on the internet  postgresql.com PostgreSQL database documentation  mysql.com MySQL database documentation  phpmyadmin.net Administrate a MySQL database via the web  oreilly.com Excellent technical books  editplus.com Notepad replacement/script editor; shareware  http://www.chiark.greenend.org.uk/ ~sgtatham/putty/ http://www.chiark.greenend.org.uk/ ~sgtatham/putty/ PuTTY free terminal utility


Download ppt "PHP, Databases, and Cookies Dave Pease IDS496 12/2/2003 www.dpease.com/php."

Similar presentations


Ads by Google