mastering php - it's alive (1)

23
© 2010, OpenThink Labs. All Rights Reserved It's Alive Add life to your static pages --rev01-- Wildan Maulana [email protected]

Upload: wildan-maulana

Post on 08-Jun-2015

1.597 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

It's Alive

Add life to your static pages--rev01--

Wildan [email protected]

Page 2: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

HTML is static and boring

Page 3: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

PHP brings web pages to life

Page 4: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Form help us capture the data

Page 5: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Forms are made of HTML

HTML acts on the Client and ....

PHP acts on the SERVER

Page 6: Mastering PHP - it's alive (1)

© 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

Page 7: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

PHP scripts must live on a server!

src: http://www.flickr.com/photos/keith324/185799373/

Page 8: Mastering PHP - it's alive (1)

© 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

Page 9: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

The server turns PHP into HTML

Page 10: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Deconstructing Owen's PHP scripts

//open : examples/ch01/final/aliens/report.php

Page 11: Mastering PHP - it's alive (1)

© 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 ($)

Page 12: Mastering PHP - it's alive (1)

© 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

Page 13: Mastering PHP - it's alive (1)

© 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

Page 14: Mastering PHP - it's alive (1)

© 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

Page 15: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

What have you learned already

Page 16: Mastering PHP - it's alive (1)

© 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>

Page 17: Mastering PHP - it's alive (1)

© 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>

Page 18: Mastering PHP - it's alive (1)

© 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 ;

Page 19: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Add New Connection on Power Architect

● Connection → Add Source Connection → New Connection

Page 20: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Create new Table Schema

Page 21: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Forward Engineer the Schema

Page 22: Mastering PHP - it's alive (1)

© 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() ;

Page 23: Mastering PHP - it's alive (1)

© 2010, OpenThink Labs. All Rights Reserved

Q&A

Thanks! ^_^