Tag Archives: PHP

CakePHP – Models Part 2

Callback Methods

If you want to sneak in some logic just before or after a CakePHP model operation, use model callbacks. These functions can be defined in model classes (including your AppModel) class. Be sure to note the expected return values for each of these special functions.

Read more

CakePHP – Models Part 1

Naming

  • Ingredient
  • extends AppModel
  • ingredient.php

The Model is automatically available to the Controller when the name matches

function index() {
//grab all ingredients and pass it to the view:
$ingredients = $this->Ingredient->find(‘all’);
$this->set(‘ingredients’, $ingredients);
}


Read more

CakePHP – Components

Naming:

  • MathComponent
  • extends Object
  • /app/controllers/components/math.php

Initialising:

var $components = array(‘Math’, ‘Session’);

When including Components in a Controller you can also declare a set of parameters that will be passed on to the Component’s initialize() method. These parameters can then be handled by the Component.
var $components = array(
‘Math’ => array(
‘precision’ => 2,
‘randomGenerator’ => ’srand’
),
‘Session’, ‘Auth’
);


Read more

CakePHP – Controllers

Naming conventions:

  • RecipesController
  • recipes_controller.php
  • extends AppController

Different Variables

var $name = ‘Recipes’;
var $uses = array(‘Recipe’, ‘User’);
var $helpers = array(‘Ajax’);
var $components = array(‘Email’);

Read more

How to Use Cookies in PHP

What is a Cookie?

A cookie is flat file based system used to represent a user of the website. It is stored on the local computer of the user. When you visit a website a cookie may be set to represent the user. Next time he visits the website, he does not need to identify himself manually; instead the cookie will represent him on that website. With the help of PHP, cookies can be created, read and destroyed.

Why do we use Cookies?

We can literally put 4000 characters of data in a flat cookie file and store information about the user preferences for a particular website. Some of the practical uses of Cookies are as follows:

  • Many sites use them to provide customized pages and results to their users. This can be achieved by storing all the information like preferences etc in a cookie.
    .
  • Many websites use cookies to log their users in automatically. By storing a few pieces of user information they can automatically authenticate the user’s details and use them to save the user time when they log in.
    .
  • Visitor tracking and statistics systems often use them to track visitors. By assigning the visitor a cookie, they will not be counted more than once, so accurate unique visitor statistics can be obtained.

Cookie Security:

Practically there is no security threat while using cookies. A cookie set by a particular website cannot be accessed or even check if it exists by another website even if it wants to. But since cookie is just a flat text file, it can be opened and read on the computer it is stored in.

If a website has stored a password in a cookie it can be read and this can pose threat to hacking. But if the same password is encrypted using a hash like md5() or sha1() then it can be more secure since this content is used to match it with the password stored on the website.

To read the full article i have written please visit: CLICK HERE

SitePoint Book Sale 5 books (PDF) / $29.95 (END Feb 13th, 2009)

I recieved a mail from sitepoint today announcing their sale in order to donate to the victims of the recent Australian bushfires. here’s the link and details of all the books they have.

Hurry up guys

http://sale.sitepoint.com

The SitePoint Client-Side Library [top]
HTML & CSS (in order of skill level)

1. Build Your Own Web Site The Right Way Using HTML & CSS (beginner)
The perfect book for absolute beginners looking to build a web site for the first time

2. HTML Utopia: Designing Without Tables Using CSS (beginner to intermediate)
The best-selling introduction to web design using CSS for layout

3. The CSS Anthology (beginner to intermediate)
A comprehensive problem/solution approach to learning CSS

4. The Art & Science of CSS (intermediate to advanced)
A showcase of inspiring, beautiful web sites and the CSS solutions behind them

5. The Ultimate CSS Reference (intermediate to advanced)
The most comprehensive reference of the CSS language available

6. The Ultimate HTML Reference (intermediate to advanced)
The most complete and up-to-date HTML Encyclopedia money can buy

7. Everything You Know About CSS Is Wrong! (intermediate to advanced)
A cutting-edge exploration of the exciting newCSS layout techniques now becoming viable thanks to IE8’s release.

DOM Scripting (in order of skill level)

1. Simply JavaScript (beginner to intermediate)
The best possible introduction to JavaScript for beginners.

2. DHTML Utopia: Modern Web Design Using JavaScript and DOM (beginner to intermediate)
A little dated now, but still a good introduction to unobtrusive JavaScript techniques

3. The JavaScript Anthology (beginner to advanced)
A comprehensive problem/solution approach to learning JavaScript

4. The Art & Science of JavaScript (intermediate to advanced)
An inspiring look at techniques that push the boundaries of JavaScript

5. Build Your Own Ajax Web Applications (intermediate to advanced)
A solid introduction to best-practice Ajax programming

Dreamweaver (in order of skill level)

1. Build Your Own Standards Compliant Website Using Dreamweaver 8 (beginner to intermediate)
Targeted at Dreamweaver users who want to move beyond “Design View”

Flash (in order of skill level)

1. The Flash Anthology (beginner to intermediate)
A collection of common problems and solutions for building Flash-based web sites

The SitePoint Server-Side Library [top]
PHP (in order of skill level)

1. Build Your Own Database Driven Website Using PHP and MySQL (beginner)
The original SitePoint book that taught so many people how to get started with PHP

2. No Nonsense XML Web Development With PHP (intermediate to advanced)
A practical, project-driven approach to reading and writing XML in PHP

3. The PHP Anthology (intermediate to advanced)
A comprehensive collection of PHP problems and solutions.

ASP.NET (in order of skill level)

1. Build Your Own ASP.NET Website Using C# and VB.NET, 3rd Edition (beginner to intermediate)
A gentle introduction to building web sites with ASP.NET 3.5

2. The ASP.NET 2.0 Anthology (intermediate to advanced)
A comprehensive collection of ready-to-use ASP.NET solutions

Ruby (in order of skill level)

1. Simply Rails 2 (beginner to intermediate)
Learn to build web applications with Ruby on Rails from scratch

Other (in order of skill level)

1. Run Your Own Web Server Using Linux & Apache (beginner to intermediate)
Learn to install and perform system administration with Linux and Apache

The SitePoint Creative Library [top]
Design Principles (in order of skill level)

1. The Principles of Beautiful Web Design (beginner to intermediate)
The best-selling guide to graphic design fundamentals for the rest of us

Photoshop (in order of skill level)

1. The Photoshop Anthology (beginner to advanced)
A practical collection of Photoshop solutions to use on any web site

The SitePoint Business Library [top]
Kits (in order of skill level)

1. The Web Design Business Kit (beginner to advanced)
The inspirational best-seller that has guided freelancers to success the world over

2. The Email Marketing Kit (beginner to advanced)
The definitive guide to planning, creating and implementing email campaigns

3. The Usability Kit (beginner to advanced)
Instructions and blueprints for performing usability analysis and testing

4. The Search Engine Marketing Kit (beginner to advanced)
A complete manual for understanding online advertising, online marketing and SEO

Productivity (in order of skill level)

1. Deliver First Class Web Sites: 101 Essential Checklists (beginner to intermediate)
A diverse collection of checklists to help you create best-practice web sites

2. The Principles of Project Management (beginner to intermediate)
An easy-to-read guide for web developers on how to successfully manage projects

3. The Principles Of Successful Freelancing (beginner to intermediate)
This book leads you through the entire process, from getting started, through to winning and keeping loyal clients

4. Outsourcing Web Projects: 6 Steps to a Smarter Business (intermediate to advanced)
Expert advice for freelancers looking to take on bigger projects