Wednesday, April 15, 2009

Ch. 8 Control Your Data, Control Your World

This chapter discussed about databases and how they relate to one another. 

Things Learned:
schemas - representation of the structures within a database
normalization - altering the design of a database to reduce duplicate data and improve placement of new data
Foreign Key - a column in a table used to relate a table to another table
for() - a loop code
? : - ternary operator used to perform simple true/false expression like a if-else statement
Inner Join - let you join table from two tables with matching rows
AS name - use as aliases to make column/table names more simple to code 

Ch. 7 cont.

Things learned:
PHP can used require_once to includes other code so that you don't have to type things over and over again.  As in, you can just include a header or footer instead of re-typing it. 
Sessions are don't last as long as cookies. 

Tuesday, March 31, 2009

Ch. 7 - Building Personalized Web Apps

This chapter talks about making a web application remember who you are by using sessions and cookies. 

Things learned:
setcookie() - this PHP code is used to set a cookie on the browser, you can provided a expiration date also in this code
$_cookie - array to store cookies
SHA (value) - encryption code to make data unrecognizable within database
session_start() - PHP code to start a new session
session_destroy () - this closes a session
$_session - array with each session data

Ch.6 Cont.

Things Learned:

We remove the HTTP script and made it's own separate file so we can include it in more than one script
This adds more security to the site and prevents people to directly accessing the page through used of a bookmark
Human moderation improves integrity on a site.
double-hyphen(--) or number sign(#) - is used to comment things out in SQL 
SQL injection - form data is used to change the operation of an SQL query
trim() - get ride of leading and trailing spaces in form data
mysqli_real_escape_string() = converts dangerous characters into an escaped format
You can default values in sql tables.
is_numeric() - making sure the value enter is numeric


Monday, March 30, 2009

Ch. 6 - Securing Your Application

This chapter discuss the importance of security and making sure you have a secure site where people can access data without permission. 

Things Learned:
HTTP provides a simple way to secure a page using PHP. When someone tries to access the admin page,  a pop window will display requesting a user name and password from the user. HTTP authentication involves establishing a line of communication between the browser and the server through HTTP. 
The dialog between the browser and server takes place through headers, little text messages with instructions. All web pages are displayed with the help of headers. 

Header function - header();
*should precede any HTML code in PHP script

Depending on what the user's types in, the headers can take three different actions: accept, retry or deny access

Different type of headers: location, refresh and content type header

"basic realm" - security zone 




Sunday, March 29, 2009

Finalized Project

I will add an event registration feature to my website: ugalambdas

The event registration will let you register for an event and if it cost money, it will let you either pay online or send in a check.

Basically, there will be a web form where the user can enter in all the necessary information. There will be validation code to check to make sure all the necessary information is entered in correctly. When the form is submitted, it will either direct the form to a online pay site or send it to a page with the address to send the check.

This project will use PHP to direct the user to the correct page after the form has been submitted.

Wednesday, March 18, 2009

Ch. 5 Cont.

Things learned:

include, include_once, require, require_once - script code that allow users to share code across multiple scripts. 
ORDER BY - an SQL command used to order things in a database
LIMIT - SQL command that limit the amount a statement can delete, this ensure accuracy of the deletion
UNLINK() - this deletes a file from the web server

Get method - used for data retrieval that doesn't change anything on the server. This method is shown in the url bar. Usually for directly sending data to server in a URL. 
Post method - used to send data to the server that somehow changes the state of the server. This method is hidden in the url bar. Usually used in web forms. 

Tuesday, March 17, 2009

Ch. 5 Working with data stored in files

This chapter discuss the used of files and databases together to build PHP applications.

Chapter example: Guitar War web site that maintain users' high scores and validates it. It needs to be able to handle a image upload.

Things learned:

SQL commands
ADD COLUMN - add a new column to the table
DROP COLUMN - remove a column from a table
CHANGE COLUMN - change the name and/or data type of a column
MODIFY COLUMN - changes the data type or position of the column in a table

$_FILES - this is another superglobal variable that provides access to information about uploaded files.

Monday, March 16, 2009

Ch. 4 Cont.

Alter Table command changes the structure of a table in a database without having to drop it and start over.
foreach is another PHP looping construct that lets you loop through an array one element at a time.

Most of the other code I learned in this chapter deals with IF statements and its operators and making sure the data can be validated.

Sunday, March 8, 2009

Project - Visualization

I want a basic website with a guestbook, gallery, forum, calendar and log in capability.

A website that would attract people to join and a secure log in page where the fraternity's member can access and see certain fraternity's files and event. Also, a forum for the brothers to discuss things on.

Wednesday, March 4, 2009

Ch. 4 realistic and practical applications

This chapter explains the problems of moving your application from testing to a live site. Validation methods are explained in this section. The chapter example is being built off chapter 3 example with sending an email to multiple recipients in a database.

Problem: the recipients are receiving more than one email at a time.
Solution: need validation code in the send email php file. Client side validation could be use also such as JavaScript. This solution is on the server side.

IF statements are used to validate the data on the sever side.

Things Learned:
-isset() - checks that a variable exists and is set
-empty()-checks to see if a variable has any contents

Sunday, February 22, 2009

Ch. 3 cont.

Instead of downloading the software to run a local server and database on my system, I've decided to just buy web space and a domain to practice my PHP and MySQL skills. I purchased the domain ugalambdas.org from Yahoo! domains and 100MB in web space from Xfluro.com hosting site.

The site is still under construction but I have a rough draft of it currently up (www.ugalambdas.org/index2.html). I will used what I learned during this semester to improve my fraternity's website.

Things Learned:
DROP command in SQL completely delete your table
DESCRIBE command analyzes the structure of your table and it's data types
mysqli_fetch_array() fetches query results into an array
WHILE Loop is used to repeat certain code when set condition is true
DELETE command can either delete all or delete only specific things if written correctly


This chapter shown me how to add and remove things from a database using a web browser and PHP scripts.

Wednesday, February 18, 2009

Ch. 3 - create and populate a database

The example in chapter 3 discussed making a database and using it to email a mass message to every person in the database.

Things Learned:
-Data in database needs to be define
-Text data type takes up the most memory to store
-VARCHAR is for data type that might not have a exact number of characters
-CHAR is for data type that you know will have an exact number of characters

I am still working through the chapter. Also, I am still trying to set up my computer to run a local server and MySQL so that I can perform the given examples.

Thursday, February 12, 2009

Chapter 2 - Finish

The functions in PHP to connect to a database and add data to it is very similar to what I've learned in 4630 with the MVC model.

mysqli_connect() - this function opens a connection between the PHP script and MySQL server so they can communicate. There are 4 important information that is needed to connect to the server database: locati0n of the database, username, password, and database name
mysqli_close() - this closes the connection to the database
mysqli_query() - this function executes the sql statement contains within the PHP code

Wednesday, February 11, 2009

Chapter 2 --- Trouble

I followed appendix ii in the book to try to configure my machine to support a database server and allow me to work locally on my computer. However, I'm having a tough time trying to get the SQL server to work correctly on my home computer, so I just went ahead and read on. The chapter mostly talked about creating tables and SQL statements which I have lots of experience of from my 4610 class and internship.

I can't really do the examples in this chapter due to my computer not being configured correctly, also I'm running a little behind schedule because of my attempts of making local server work.

Some tools to access the MySQL database server are MySQL terminal and phpMyAdmin. MySQL is more hard coded tool as in you will used SQL statements to make the tables and data entry whereas phpMyAdmin is more of a graphical user-friendly tool that help with making the tables easier.


SQL Syntax
-Insert
-Select
-Put a semicolon(;) at the end of statement

Tuesday, February 10, 2009

Chapter 2 - connecting to MySQL

Chapter 2 deals with MySQL and how to store data on a database server. The example from chapter 1 deals with receiving emails from different users, but the emails can be a little overwhelming if many people uses the form. So in chapter 2 they discussed using a MySQL database to better organized data and easily access it.

I am currently trying to configure my computer to have a database server on it, so that I can perform the examples in the book.

Finalized Schedule (Updated again)

Chapter -- Due Date
1 -- Feb. 4, 2009
2 -- Feb. 11, 2009
3 -- Feb. 18, 2009
4 -- Feb. 25, 2009
5 -- Mar. 4, 2009
6 -- Mar. 18, 2009
7 -- Mar. 25, 2009
8 -- Apr. 1, 2009
9 -- Apr. 8, 2009

Sample Project --- Last 1-3 weeks of school

Tuesday, February 3, 2009

Chapter 1 - part 3(final)

Things Learned
-$_POST is a special variable called superglobal and it holds data
-$_POST is an array
-a period(.) is used for concatenation
-escape characters = represent characters in PHP that are difficult to type or conflict with other code
-PHP has a couple of escape characters -- \' - single quotes -- \"- double quotes -- \n - newlines
- \n has to be in double quoted statement or they won't work
-mail() is the code to send an email in PHP
-echo a PHP command for sending output to browser window

Monday, February 2, 2009

Chapter 1 - part 2

I read 2/3 of Chapter 1.

New things learned:
-PHP always need a server to be able to run
-Using a simple code you can test to see if your server provider supports PHP:

[< ?php
phpinfo();
?>]

Create a file called test.php, put it on your server and enter its URL into a web browser. If the browser displays information about PHP then your server supports PHP.
-PHP is dynamic
-PHP is always enclose by
- Each ends with a ;
- variable names must begin with $ and can only have _ in them, no spaces or any other special characters
-good naming convention = all lowercase and separate multi-word variable with underscores
-PHP is only case sensitive when its variable name but is insensitive when its commands




Example 1

Updated Schedule

Chapter -- Due Date
1 -- Feb. 4, 2009
2 -- Feb. 11, 2009
4 -- Feb. 18, 2009
5 -- Feb. 25, 2009
6 -- Mar. 4, 2009
7 -- Mar. 18, 2009
8 -- Mar. 25, 2009
9 -- Apr. 1, 2009

Sample Project --- Last 1-3 weeks of school

Tuesday, January 27, 2009

Chapter 1 - part 1

I read about 1/3 of chapter 1. This book have a lot of diagrams and charts which makes the concept easier to understand. I really enjoy reading the book.

Concepts I learned so far:
-PHP is contained and run on the server
-PHP makes the website more interactive
-files extension of PHP files is .php
-PHP originally stood for Personal Home Pages
-PHP file has to be link to the html file

Tuesday, January 20, 2009

Book Selection

I used Barnes and Noble and Borders online websites to help me select a book. After reading a couple of reviews and researching online about a few book, I decided to go with Head First - PHP & MySQL.

I brought the book at Borders since I did not want to order and wait for it to come in. The book gives plenty of examples and explanations of every concept, so it is easy to follow.

Schedule - Rough Draft

Week 1 - Chapter 1
Week 2 - Chapter 2
Week 3 - Chapter 3
Week 4 - Chapter 4
Week 5 - Chapter 5
Week 6 - Chapter 6
Week 7 - Chapter 7
Week 8 - Chapter 8
Week 9 - Chapter 9
Week 10 - Chapter 10
Week 11 - Chapter 11
Week 12 - Chapter 12

I also like to create my fraternity's website using what I learn as a project.

Monday, January 19, 2009

PhP Tutorials

I've discover some PhP tutorials on the web:

http://www.w3schools.com/PHP/DEfaULT.asP

http://www.tizag.com/phpT/

YouTube also have some good video tutorials that I could take advantage of. I am still in the process of choosing a PhP book.

Thursday, January 8, 2009