Mais conteúdo relacionado
Semelhante a Mastering PHP - it's alive (1) (20)
Mais de Wildan Maulana (20)
Mastering PHP - it's alive (1)
- 1. It's Alive
Add life to your static pages
--rev01--
Wildan Maulana
wildan.m@openthinklabs.com
© 2010, OpenThink Labs. All Rights Reserved
- 2. HTML is static and boring
© 2010, OpenThink Labs. All Rights Reserved
- 3. PHP brings web pages to life
© 2010, OpenThink Labs. All Rights Reserved
- 4. Form help us capture the data
© 2010, OpenThink Labs. All Rights Reserved
- 5. Forms are made of HTML
HTML acts on the Client and ....
PHP acts on the SERVER
© 2010, OpenThink Labs. All Rights Reserved
- 6. Use PHP to Access the Form Data
$_POST['var_name'] ...... [1]
$_GET_['var_name'] ...... [2]
1. http://php.net/manual/en/reserved.variables.post.php
2. http://php.net/manual/en/reserved.variables.get.php
© 2010, OpenThink Labs. All Rights Reserved
- 7. PHP scripts must live on a server!
src: http://www.flickr.com/photos/keith324/185799373/
© 2010, OpenThink Labs. All Rights Reserved
- 8. 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
- 10. Deconstructing Owen's PHP scripts
//open : examples/ch01/final/aliens/report.php
© 2010, OpenThink Labs. All Rights Reserved
- 11. 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
- 12. 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
- 13. Variables are for storing script data
● $where = “at home”
● $_POST[“email”] = “twetme@someplace.com”
//see : slide 6, for more information about $_POST and $_GET variable
© 2010, OpenThink Labs. All Rights Reserved
- 14. 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
- 15. What have you learned already
© 2010, OpenThink Labs. All Rights Reserved
- 16. ● #svnadmin create /home/svn/training
● #apt-get install libapache2-svn
<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>
● 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
© 2010, OpenThink Labs. All Rights Reserved
- 17. 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
- 18. 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
- 19. Add New Connection on Power Architect
● Connection → Add Source Connection → New
Connection
© 2010, OpenThink Labs. All Rights Reserved
- 22. ● 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
- 23. Q&A
Thanks! ^_^
© 2010, OpenThink Labs. All Rights Reserved