mastering php - it's alive (1)
TRANSCRIPT
© 2010, OpenThink Labs. All Rights Reserved
It's Alive
Add life to your static pages--rev01--
Wildan [email protected]
© 2010, OpenThink Labs. All Rights Reserved
HTML is static and boring
© 2010, OpenThink Labs. All Rights Reserved
PHP brings web pages to life
© 2010, OpenThink Labs. All Rights Reserved
Form help us capture the data
© 2010, OpenThink Labs. All Rights Reserved
Forms are made of HTML
HTML acts on the Client and ....
PHP acts on the SERVER
© 2010, OpenThink Labs. All Rights Reserved
Use PHP to Access the Form Data
$_POST['var_name'] ...... [1]$_GET_['var_name'] ...... [2]
1. http://php.net/manual/en/reserved.variables.post.php2. http://php.net/manual/en/reserved.variables.get.php
© 2010, OpenThink Labs. All Rights Reserved
PHP scripts must live on a server!
src: http://www.flickr.com/photos/keith324/185799373/
© 2010, OpenThink Labs. All Rights Reserved
Get your PHP scripts to the server
Copy the example scripts to the root directory of the server, or .....
You can setup a new virtual host
© 2010, OpenThink Labs. All Rights Reserved
The server turns PHP into HTML
© 2010, OpenThink Labs. All Rights Reserved
Deconstructing Owen's PHP scripts
//open : examples/ch01/final/aliens/report.php
© 2010, OpenThink Labs. All Rights Reserved
A few PHP rules to code by● PHP code always enclosed by <?php and ?>● Every PHP statement must end with semicolon (;)● If there is any PHP code in a web page, it's a
good idea to name the file on the web with .php not .html
● PHP variable must begin with a dollar sign ($)
© 2010, OpenThink Labs. All Rights Reserved
Finding the perfect variable name● The first character must be a dollar sign ($)● A variable name must be at least one character in length ● The first character after the dollar sign can be a letter or an
underscore (_), and characters after that can be a letter, an underscore, or a number
● Spaces and special character other than _ and $ are not allowed in any part of variable name
● (+) Use lowercase for variable name ● (+) Separate words in a multi-word variable name with
under score
© 2010, OpenThink Labs. All Rights Reserved
Variables are for storing script data● $where = “at home”● $_POST[“email”] = “[email protected]”
//see : slide 6, for more information about $_POST and $_GET variable
© 2010, OpenThink Labs. All Rights Reserved
Sending Email with PHP
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
//see : http://id2.php.net/manual/en/function.mail.php
© 2010, OpenThink Labs. All Rights Reserved
What have you learned already
© 2010, OpenThink Labs. All Rights Reserved
● #svnadmin create /home/svn/training
● #apt-get install libapache2-svn
● svn mkdir -m "created default directory structure" http://training.o2labs/svn/training/trunk http://training.o2labs/svn/training/tags http://training.o2labs/svn/training/branches
<Location /svn/training> DAV svn SVNPath /home/svn/training AuthType Basic AuthName "Training subversion repository" AuthUserFile /etc/subversion/passwd <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept></Location>
© 2010, OpenThink Labs. All Rights Reserved
Creating Apache Alias
Alias /headfirst/ "/path/to/examples" <Directory "/path/to/examples"> Options Indexes MultiViews FollowSymLinks AllowOverride None </Directory>
© 2010, OpenThink Labs. All Rights Reserved
Create Database● mysql> create database headfirst ;● mysql> grant all on headfirst.* to
'headfirst'@'localhost' identified by 'jagungbakar' ;● mysql> flush privileges ;
© 2010, OpenThink Labs. All Rights Reserved
Add New Connection on Power Architect
● Connection → Add Source Connection → New Connection
© 2010, OpenThink Labs. All Rights Reserved
Create new Table Schema
© 2010, OpenThink Labs. All Rights Reserved
Forward Engineer the Schema
© 2010, OpenThink Labs. All Rights Reserved
● DOM – Document Object Model● CSS : CSS selector
– #firstname {background-color:red;font-wight:bold}– .input → css class
● JavaScript - jQuery– $(“#firstname”).val() ;
© 2010, OpenThink Labs. All Rights Reserved
Q&A
Thanks! ^_^