Search This Blog

Sunday, July 29, 2012

Day 36 - 40 : Project Finishing & Assessment

This would be your final week. You should be on your final steps on your project. A few things will be on this week's list:

  • I need to make sure you guys are in the smooth progress on your shopping cart
  • Then we'll be looking into checkout process : payment & shipping, paypal sandbox.
  • MVC, maybe?
  • CMS, maybe?
  • Overall Quiz on what we've learned this 2 months
  • Feedback, Q&A

Sunday, July 22, 2012

PayPal Web Service


- Web Services are application interfaces made available via the World Wide Web; in oo terms, it can be seen as a class that exposes its public methods via the web.
- Example: google, paypal, etc. 
- You may continue with the paypal web service when your e-commerce project on the final stage. Which mean the stage of getting the user to submit payment.

Day 31 - 35 : Shopping Cart

Day 31 - 35


  • This final 2 weeks would be more time spending on your project; you may voice out any question or if you wish any topics to have further explanation. 
  • For those that haven't start anything on the project, or want to try something other that e-commerce, you may suggest to me what you have on mind, orget some idea from here:
  1. Mail editing and sending system(with PHP)
    Project description : Please create a system to send email asynchronously about 100,000. you may consider PEAR or other framework
    The system also needs to be able to edit the HTML mail.
  2. Tourist Site
    A site similar to http://www.visitmaine.com/
    structure and functionality of http://www.visitmaine.com/
    Graphic Design similar to http://www.colombia.travel/en/
    Using latest versions of PHP and Joomla.
    Bilingual skeleton for English and (Chinese/Arab/Malay/Tamil/Spanish). Leave frame for third language in future.
    Easy to mantain for Website Manager.
    Easy to customize content and images for staff writers.
    SEO friendly.
    Crossbrowser compatibility. IExplorer, Firefox, Chrome, Safari
  3. To-Do Task List Cloud Offering
    Description: build a To-Do task list service offered through the cloud.
    We'd like service providers to provide effort and cost estimates for providing design and development services for this service.
    High level functional requirements include:
    1.            Sign in via Facebook
    2.            Create a task
    3.            Create a note
    4.            Create a “group” of tasks
    5.            Assign other individuals to a group
    6.            Assign other individual to a task
    7.            Change the status of a task
    8.            Select a due date for a task
    9.            Create dependencies between tasks
    Similar websites that we like are the following. Functionality will be similar to these:
    http://www.rememberthemilk.com




Saturday, July 14, 2012

Day 26 - 30 : Accessing MySQL db from the Web with PHP, Authentication

Day 26: [txtbk Chapter 11] connect  and process database access: select, insert
  1. $db = new mysqli(...);
  2. check bd connection error? mysqli_connect_errno()
  3. connection ok, $db->real_escape_string()
  4. $db->query(); ex: $result = $db->query()
  5. if the query "SELECT", $result->num_rows; 
    • if "UPDATE / INSERT", $db->affected_rows;
  6. make a loop to retrieve data from db [for / while] 0 to num_rows-1
    • $row = $result->fetch_assoc();
    • get the db data ex: $row['id'], $row['name']
  7. $result->free();
  8. $db->close();


Day 27: 
  • update
  • encryption, date & time Function in MySQL
  • prevent SQL injection : preparedStatement 
    • bind_param variables -i, d, s, b 
    1. $db = new mysqli(...);
    2. check bd connection error? mysqli_connect_errno()
    3. ex: $query = "select name from books where isbn=?"; //value replace to ? in query
    4. $db->prepare(); ex: $stmt = $db->prepare($query);
    5. $stmt->bind_param('s', $isbn); //if 1 ? then, parameter type 's' refer to its type, and the $isbn refer to the value of the ?
    6. if the query "SELECT",  $stmt->bind_result($name);
    7. $stmt->execute();
    8. if the query "SELECT", $stmt->store_result();
    9. if the query "SELECT", $stmt->num_rows; 
      • if "UPDATE / INSERT", $stmt->affected_rows;
    10. make a loop to retrieve data from db using while : $stmt->fetch()
      • get the db data ex: $name // as what the parameter we keep for bind_result
    11. $stmt->free_result();
    12. $stmt->close();
    13. $db->close();

Day 28: 
  • [txtbk Chapter 17] Implement Authentication with PHP & MySQL
  • [txtbk Chapter 23] Using Session Control

Day 29:
  • [txtbk Chapter 27] Building User Authentication and Personalization
  • [txtbk Chapter 34] Web 2.0 Applications with Ajax
    • step to change chapter 27 codes to be ajax  :--
    • insert new_ss.css and new_ajax.js to project chapter27
    • amend function display_add_bm_form() in output_fns.php
    • amend do_html_header() in  output_fns.php
      • link external js and css
    • modify add_bms.php
      • remove --- do_html_header('Adding bookmarks');
      • remove ---  display_user_menu();
      • remove ---  do_html_footer();
      •  remove --- check_valid_user();
      • remove --- try block and exception handling to something make sense in ajax environment 
      • add else(s)
    • modify url_fns.php
      • in function add_bm() : throw change to echo(s); add else; remove --- return true;
Day 30:
  • [txtbk Chapter 28] Building a Shopping Cart

Friday, July 13, 2012

MySQL Quiz

  1. create a database "MyDatabase"
  2. create a table "MyTable", with 4 fields[id, name, password,dateCreated]
  3. delete data from "MyTable" which have name begin with 'A'
  4. insert 3 rows of data with this information:
    • name:Ali, Johan, Frankie; password: ali123, johan123, frankie123
  5.  update data from "MyTable", change the  name to "Ali Adam", "Johan Harry", "Frankie Tom"
  6. empty the table / delete all data from "MyTable"
  7. Sort "MyTable" in descending order according to "name" field
  8. add a new field "age" to "MyTable"
  9. remove "MyTable" from "MyDatabase"
  10. u have 2 tables user(id, name, password), and activity(id, userid, activityName)
          join these 2 table and show the data of user's name and his activity.

Friday, July 6, 2012

Day 21 - 25: MySQL

Day 21: Relational Database Concepts
  • Database intro
  • Tables, Columns, Rows, Values, Keys, Schemas
  • Relationship: 1-1, 1-many, many-many
  • database diagram, database dictionary
  • database fundamentals
  • mySQL monitor : c:\xampp\mysql\bin -> mysql.exe -u root [-p]
  • create database, drop
  • php connect to mySQL DB
  • mySQL Administration DCL: create user, grant ... to, revoke ... from, privileges
  • Storage Engines/Table Type : myisam, innodb
  • Data Types : 
    • numeric - tinyint(bool), int
    • float - float(m,d, double)
    • date & time: date, time, datetime, timestamp
    • string: char(fix length char), varchar; text, blob[binary large object:example-image]
  • DDL: create, alter, drop  table

Day 22-23:
  • DML: insert, update, delete
  • DQL: select ... where
  • indexing
  • keyword: 
    • null, not null, auto_increment, unsigned(int)
    • distinct, order by asc|desc, limit
  • operator:
    • =, >, <, >=, <=, !=, 
    • is null, is not null, between, in, not in, like("%"), not like, regexp
  • join type: union, inner join, left join
  • grouping & aggregating
    • group by... having
    • avg(), count(), min(), max(), sum()
  • subqueries: any, in , some, all
Day 24-25:

Thursday, July 5, 2012

Day 19 : Quickform2 tutorial

// Load the main class
require_once 'HTML/QuickForm2.php';

// Instantiate the HTML_QuickForm2 object
$form = new HTML_QuickForm2('tutorial');

// Set defaults for the form elements
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
'name' => 'Joe User',
'Gender' => '1',
'status' =>'1'
)));

// Add some elements to the form
$fieldset = $form->addElement('fieldset')->setLabel('QuickForm2 tutorial example');
$name = $fieldset->addElement('text', 'name', array('size' => 50, 'maxlength' => 255))
->setLabel('Your name:');
$email = $fieldset->addElement('text', 'email', array('size' => 50, 'maxlength' => 255))
->setLabel('Your Email:');

$gender1= $fieldset->addElement('radio', 'gender[]', array('value' => 1),
array('content' => 'male', 'label' => 'male'));
$gender2= $fieldset->addElement('radio', 'gender[]', array('value' => 2),
array('content' => 'female', 'label' => 'female'));

$options = array('KL','Melaka','Sabah', 'Srwk');
$location= $fieldset->addElement('select', 'location', array('multiple' => 'multiple', 'size' => 4),
array('options' => $options, 'label' => 'Multiple select Location:'));

$status1= $fieldset->addElement('checkbox', 'status[]', array('value' => 1),
array('content' => 'single'));
$status2= $fieldset->addElement('checkbox', 'status[]', array('value' => 2),
array('content' => 'married'));
$fieldset->addElement('submit', null, array('value' => 'Send!'));

// Define filters and validation rules
$name->addFilter('trim');
$name->addRule('required', 'Please enter your name');
$email->addFilter('trim');
$email->addRule('required', 'Please enter your email');
$email->addRule('regex', 'valid email address please','/^(\w+[\-\.])*\w+@(\w+\.)+[A-Za-z]+$/');

// Try to validate a form
if ($form->validate()) {
echo '<h1>Hello, ' . htmlspecialchars($name->getValue()) . '!</h1>';
//echo "<br/>".$email->getValue()."<br/>";
//var_dump($form->getValue());
//echo "<br/>".$form->getValue('name')."<br/>";
//echo "<br/>".$form['status']->getValue()."<br/>";
$post = $form->getValue();
//var_dump($post);
//var_dump($location->getValue();
var_dump($post['status']);
exit;
}

// Output the form
echo $form;