Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Programming with CodeIgniter MVC
Programming with CodeIgniter MVC

Programming with CodeIgniter MVC: Build feature-rich web applications using the CodeIgniter MVC framework

eBook
$9.99 $22.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Programming with CodeIgniter MVC

Chapter 1. Getting Started

This chapter covers the basics of the CI development framework and its usage by reviewing some fundamental web application examples. We will start with a basic hello world example and move to an interactive contact-form integration with a database. We will construct the CI applications by following a step-by-step method. Throughout this chapter, we need to remember that the CI development framework is an MVC-based development architecture (for more information, refer to the Wikipedia definition at http://en.wikipedia.org/wiki/Model-view-controller).

This chapter will primarily focus on the following topics:

  • The CI project directory tree framework

  • Configurations (routing and autoloading are covered in this chapter, while the other issues are covered in Chapter 2, Configurations and Naming Conventions)

  • Example 1: hello world

  • Example 2: passing parameters to a view

  • Example 3: the database query by a model rendering results to a view

  • Example 4: interactive contact forms

By reviewing these examples, we will get the basics of using CI resources. We will begin by briefly reviewing the CI resources used. Then we will review a web application code that loads a static view page. Next we will use the model to retrieve data from a database and show it in a view. Finally, we'll add a view with a contact form to enter input and save it by calling a controller method into the database.

Installing CodeIgniter


First of all, we need to have a hosted PHP server (Version 5.3 or later) and a MySQL (one of the latest versions) server, where we know the database credentials. Local database access from the PHP is recommended for simplicity.

Note that the server will operate in a CGI (Common Gateway Interface) fashion in order to let CI operate. We can have a local web development environment on our PC or a remote server hosted and dedicated.

Once we've set up a local web development environment, we'll need to download the latest version of CI, which is Version 2.1.2 at the time of writing this book. The link to download the latest version is http://codeigniter.com/downloads/. Now, if we look inside the CI folder, we should see the following directory tree:

codeigniter/
  index.php
  application/
  cache/
  config/
  controllers/
  core/
  errors/
  helpers/
  hooks/
  language/
  libraries/
  logs/
  models/
  third_party/
  views/
  system/
  core/
  database/
  fonts/
  helpers/
  language/
  libraries/

Folders overview


The root folder contains the index.php file, which handles all the URI requests. The index.php file will process them with the CI core, and apply our application controllers using the models, libraries, and helpers loaded by the controllers and rendered views, license.txt, which is the CI's license file. .htaccess is used for configuring the CI routing and removing index.php from the URL. JavaScript, CSS, and HTML is incorporated into the rendered PHP output and their usage is elaborated in Chapter 7, Views.

Let's review the folders and their content application.

The application directory folder is the root directory of our main activity project coding zone. This is the heart of the CI-developed application project.

Mandatory components

Let's take a look at the mandatory components.

  • application/config: This folder contains all the CI application configuration files, which are covered in Chapter 2, Configurations and Naming Conventions.

  • application/controllers: This folder contains all the application controllers in the CI application project. A controller, as mentioned in the Preface, is a component in the MVC-design architecture that handles the request by the user and presents the data shown to the user. A controller in CI is a class extending a base class of the CI controller. The class methods can be executed or called with a proper URI. The naming conventions related to the controller definition and usage will be covered in Chapter 2, Configurations and Naming Conventions.

  • application/views: This folder contains all the view files. A view is the HTML content executed by the user browser that presents and interacts with the user. A view can be a webpage or an RSS page.

The following components are not mandatory but are highly recommended:

  • application/models: This folder contains all the project model files. A model is the component of the MVC design architecture, which handles the data stored in the database. A model in CI is a PHP class that is designed to work with the information in the database. Chapter 6, Models, will elaborate on the CI models concept, definition, and usage with several usage examples.

  • application/helpers: This folder contains all the additional helper files to the CI helpers. They can be third-party or created by the developer. A helper file is a collection of independent procedural functions in a particular category. Each helper function performs one specific task, with no dependence on other functions. Chapter 5, Helpers, will elaborate on the CI helpers concept, definition, and usage with several usage examples.

  • application/libraries: This folder contains all the libraries of the CI application project created by the developer. A CI library is technically a PHP class. The scope of the library can be any project resource, such as helpers, models, controllers, and views. For example, a library can provide Facebook library API services to simplify the application code for Facebook integration. Chapter 4, Libraries, will elaborate on the CI libraries concept, definition, and usage with several usage examples.

  • system: This is the root of the CodeIgniter core directory. The system folder contains important system components in the subfolders, such as core, database, helpers (built-in system helpers), and libraries (built-in system libraries).

    Tip

    Do not edit any of these files! Upgrading is much easier if we don't.

Example 1 – hello world


Initially, we will start with a simple example that displays Hello World on the rendered web page. This is an example that doesn't use a database.

The URI will be http://ourdomain.com/index.php/hello.

We can eliminate the index.php file from the path to enable a shorter URI; that is, http://ourdomain.com/index.php/hello.

In order to enable these shorter URIs, we will make configuration changes as described in Chapter 2, Configurations and Naming Conventions, regarding the config.php index_page setting in config.php.

We will build the following two scripts:

  • Controller class: application/controllers/hello.php

  • View script: application/views/helloview.php

In this example, we use the default configuration. For more information about configurations, refer to Chapter 2, Configurations and Naming Conventions. The controller in this example passes the parameters that are displayed in the view.

Tip

Passing the parameters from the controller to the view is optional.

The controller file

Here's the code sample of the controller. The controller is responsible for rendering the view with the parameters, such as mega title and message. For naming the controller classes, refer to Chapter 2, Configurations and Naming Conventions.

<?php 
class Hello extends CI_Controller {
  * Index Page for this controller.
  * Maps to the following URLhttp://example.com/index.php/hello
  - or - http://example.com/index.php/hello/index- or -* since this controller is set as the default controller in config/routes.php, it's displayed at http://example.com/
  * So any other public methods not prefixed with an underscorewill map to /index.php/welcome/<method_name>
  @see http://codeigniter.com/user_guide/general/urls.html
  public function index(){	    
    // Note that $view_params is optional// we can use $this->load->view('helloview');as well.// if the view doesn't use php variables 
    // The $view_params is extracted in the view script to php// variables $key = $value
    // In this example three variables will be generated by CI in the // view page
    // helloview.php variable: $mega_title
    // value: 'Codeigniter - Hello World'		// variable: $title      value: 'Welcome to // Codegniter'// variable: $message    value: 'Hello World'
    $view_params = array(
    'mega_title' => 'Codeigniter - Hello World', 'title'      =>  'Welcome to Codegniter','message'    =>  'Hello World'                              );		
			$this->load->view('helloview', $view_params);		}
	} // closing the class definition
/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */

Tip

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

The view file

The following is the corresponding rendered view that uses the parameters provided by the controller to render the view to the web page and return it to the user:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title><?php echo $mega_title ?></title>
</head>
<body>
  <div id="container">
  <h1><?php echo $title ?></h1>
  <div id="body">
  <p><?php echo $message ?></p>
</div></div>
</body>
</html>

Example 2 – passing the complex parameters to a view


In this example, we will show you how to pass and use complex parameters, such as arrays and object arrays, from the CI controller to the rendered CI view to be used in the view. You can pass any number of arrays as parameters to a view; you can also pass objects, such as rows of a query result.

A standard GET parameters URI looks like this: http://ourdomain.com/index.php/example2/more/?a=1&b=2&c=3.

However, let's remember that in CI the URI is passed in this manner: http://ourdomain.com/index.php/example2/more/1/2/3. For more information, see Chapter 2, Configurations and Naming Conventions.

Looking at the URI, we will build the controller example2.php with the function named more with the three parameters passed to it.

We will build the following two scripts:

  • The controller class: application/controllers/example2.php

  • The view script : application/views/ example2more.php

The controller file

The controller is responsible for rendering the view with parameters such as mega title and message.

The following is the code sample of the controller:

<?php 
class Example2 extends CI_Controller {
  //This function gets parameters and passes them to the view//example2more
  //The example url//http://ourdomain.com/index.php/example2/more/1/2/3
  so $a = 1, $b = 2, $c = 3
  public function more($a, $b, $c)
  {
    // The parameters in $view_params are extracted in the view//example2more.php
    // In this example 2 variables will be generated by CI in the//view page example2more.php
    //variable: $mega_title, value: Codeigniter, Passing//url parameters to view
    variable: $rows, value: array('a' => $a, 'b' => $b, 'c' => $c);
    $rows = array('a' => $a, 'b' => $b, 'c' => $c);
    $view_params = array('mega_title' => 'Codeigniter -  Passing url parameters to view 'rows' => $rows);
    $this->load->view('example2more', $view_params);
    }	}// closing the class definition/* End of file welcome.php

The view file

The following is the corresponding rendered view:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title><?php echo $mega_title ?></title>
</head>
<body>
<table>
<tr>
  <td>Key</td>
  <td>Value</td>
</tr>
<?php foreach ($rows as $key => $value): ?>
<tr>
  <td><?php echo $key ; ?></td>
  <td><?php echo $value ; ?></td>
</tr> 
<?php endforeach; ?>
</table>
</body>
</html>

Example 3 – the database query by a model rendering results to a view


In this example, we will show you how the CI controller uses the CI model to retrieve data from the database and render it to a CI view.

The URL will be http://ourdomain.com/index.php/user.

First, we will have to configure the database settings in the configuration file application/config/database.php.

We should keep the default database settings unchanged, and only change the following configuration parameters:

$db['default']['hostname'] = '127.0.0.1';
//In many cases when the hostname's value is 'localhost' theconnection to the database fails.
//Setting the hostname to 127.0.0.1 solves the problem.
$db['default']['username'] = 'dbUser;
$db['default']['password'] = 'dbPassword';
$db['default']['database'] = 'dbDataAbse';
$db['default']['port']     = 'dbPort';

The model class will retrieve all the user details from the table users.

For more information on configurations, refer to Chapter 2, Configuration and Naming Conventions.

We will build the following three scripts:

  • The controller class: application/controllers/user.php

  • The model file: application/model/usermodel.php

  • The view script: application/views/userview.php

The controller file

The controller retrieves the users list from the database via the model and renders the view with it.

The following is the code sample of the controller:

<?php
class User extends CI_Controller {
  function users()
  {
    //Manually loading the database
    $this->load->database();
    //Loading the model class
    $this->load->model('Usermodel');
    $view_params['mega_title'] = 'Model Example';
    //Calling the model to retrieve the users from the database
    $view_params['users']= $this->Usermodel->get_users();
    $this->load->view('userview', $view_params);
  }
}
/* End of file welcome.php */
/* Location: /application/controllers/welcome.php */

The model file

The following is the code sample of the model.

<?php
class Usermodel extends CI_Model {
  function __construct()
  {
    // Call the Model constructor	parent::__construct();
  }
  //This method retrieves the users list and returns an array of //objects each containing user details
  function get_users()
  {
    //Calling CI's database object's method for generating SQL//queries.
    $query = $this->db->get('users');
    //returns an array of users objects
    return $query->result();
  }
}

In this example, the CI object database's method is called for generating and executing the SQL query.

Please refer to the CI database's library at http://ellislab.com/codeigniter/user-guide/database/index.html.

For more information about models, refer to Chapter 6, Models.

The view file

The view in this example shows the table content received from the controller containing the users list as defined in the database.

The following is the corresponding rendered view:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title><?php echo $mega_title ?></title>
</head>
<body>
<table>
<tr>
  <td>ID</td>
  <td>Name</td>
  <td>Email</td>
</tr>
<?php foreach ($users as $user): ?>
<tr>
  <td><?php echo $user->user_id ?></td>
  <td><?php echo $user->user_fname." ".$user->user_lname; ?></td>
  <td><?php echo $user->user_email ; ?></td>
</tr>
<?php endforeach; ?>
</body>
</html>

Example 4 – interactive contact forms


This example shows how to write a contact form using the CI form helper and the form_validation library.

For more information about libraries, refer to Chapter 4, Libraries, and for information about helpers, refer to Chapter 5, Helpers.

The CI controller defines a form validation setup using the form_validation library and renders a form view that uses the form_validation library setup to apply a desired validation on the submitted data by the user. If it's a success, the CI controller will render a view page displaying a success message, otherwise it will render the view page with the form and the error messages will be displayed.

The URI for this example is http://ourdomain.com/index.php/contact.

In order to perform this example, we shall build the following three scripts:

  • The contact form controller class: application/controllers/contact.php

  • The view form script: application/views/contactview.php

  • The view success page script: application/views/contactsuccess.php

The controller file

The controller creates a form for adding and editing a product.

For more information, refer to Chapter 7, Views.

The following is the code sample of the controller:

<?php
class Contact extends CI_Controller {
  public function index()
  {
    //Loading the form helper
    $this->load->helper('form');
    //Loading the form_validation library
    $this->load->library('form_validation');
    $view_params['form']['attributes'] = array('id' =>'myform');
    //contact name details
    $view_params['form']['contact_name']['label'] = array('text' => 'Your name:', 'for' => 'name');
    $view_params['form']['contact_name']['field']= array('name' => 'contact_name', 'id' => 'contact_name','value'=>isset($_POST['contact_name']) ?
    $_POST['contact_name'] : '',
    'maxlength' => '100', 'size' => '30', 'class' => 'input');
    //contact name details
    $view_params['form']['contact_email']['label'] = array('text' => 'Your email:', 'for' => 'email');
    $view_params['form']['contact_email']['field'] = array('name' => 'contact_email', 'id' => 'contact_email','value'=> isset($_POST['contact_email']) ?
    $_POST['contact_email'] : '',
    'maxlength'   => '100', 'size' => '30', 'class' => 'input');
    //contact message details
    $view_params['form']['contact_message']['label'] = array('text' => 'Your message:', 'for' => 'message');
    $view_params['form']['contact_message']['field'] = array('name' => 'contact_message', 'id' => 'contact_message','value' => isset($_POST['contact_message']) ?
    $_POST['contact_message'] : '',
    'rows' => '10',  'cols' => '100', 'class' => 'input');
    // Setting validation rules
    $config_rules = array(array('field' => 'contact_name','label' => 'Contact Name', 'rules' => 'trim|required'),
    array('field' => 'contact_email', 'label' => 'Contact Email','rules' => 'trim|required|valid_email'));
    $this->form_validation->set_rules($config_rules);
    $this->form_validation->set_rules('contact_message','Contact Message', 'trim|required');
    // Validating the form
    if ($this->form_validation->run() == FALSE)
    // failed 
    {
      for ($index = 0; $index < count($a_fields) $index++);
      {
        $s_field = $a_fields[$index];
        if (form_error($s_field))
        {
          $view_params['form'][$s_field]['field']['class'] .= 'error';
          }
        }
      $this->load->view('contactview', $view_params);
      }
      else // Validation succeeded
      {
      $success_params = array('message'=> 'Success');
      $this->load->view('contactsuccess', $success_params);
      }
    }
  }
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

The view file

The view file displays the contact form for receiving data from the user.

The following is the corresponding rendered form view:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Form Example</title>
</head>
<body>
<?php if (validation_errors()) : ?>
  <?php echo validation_errors() ; ?>
  <?php endif; ?>
<?php echo form_open('contact', $form['attributes']) ; ?>
<table>
<tr>
  <td><?php echo form_label($form['contact_name']['label']['text'],
$form['contact_name']['label']['for']);?> 
  </td> 
  <td><?php echo form_input($form['contact_name']['field']); ?></td>
</tr>
<tr>
  <td><?php echo form_label($form['contact_email']['label']['text'],
$form['contact_email']['label']['for']);?>
  </td> 
  <td><?php echo form_input($form['contact_email']['field']);?>
  </td>
</tr>
<tr>
  <td><?php echo
  form_label($form['contact_message']['label']['text'],
  $form['contact_message']['label']['for']); ?>
  </td> 
  <td><?php echo form_textarea($form['contact_message']['field']);?>
  </td>
</tr>
<tr>
  <td colspan="3"><?php echo form_submit('mysubmit', 'Send'); ?></td>
</tr>
</table>
<?php echo form_close() ; ?>
</body>
</html>
The following is the corresponding rendered success view:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Contact sent</title>
</head>
<body>
<div id="container">
  <div id="body">
    <p><?php echo $message ?></p>
  </div>
</div>	
</body>
</html>

Summary


In this chapter we have reviewed the CI directory tree, especially the application folder, which is the heart and soul of any CI project. In the next chapter, we will review the configurations, such as database and naming conventions that are essential for the CI project.

Left arrow icon Right arrow icon

Key benefits

  • Build feature-rich web applications using the CodeIgniter MVC framework
  • Master the concepts of maximum simplicity, separation, flexibility,reusability, and performance efficiency
  • A guick guide to programming using the CodeIgniter MVC framework

Description

The CodeIgniter Model-View-Controller framework provides genius simplicity, flexibility, and efficient resource usage, boosting performance and reusability. "Programming with CodeIgniter MVC" reviews the unique features of CodeIgniter using simple, easy-to-follow, and practical examples. Programming with CodeIgniter MVC provides a simple step-by-step guide to efficiently utilizingthe CodeIgniter MVC framework for developing web applications. This book is packed with engaging examples to understand the usage of controllers, libraries, and (Codeigniter) CI Models. This book commences with a quick discussion of the CodeIgniter Integration with  external plugins such as Flickr API, Google Maps and more will be reviewed with clear usage examples. It will then cover CI naming convention rules, mandatory and optional configurations, and usage within a CI project. It will also cover user defined configurations. By the end of this book, you will not only understand user-defined libraries in a CI framework, but also their services, role, usage, and scope with the help of an example-based approach. The book also covers helpers, models, and views, as well as their usage. Using this book, youwill soonbe able to develop feature-rich web applications using the CodeIgniter MVC framework. "Programming with CodeIgniter MVC" is a one-stop solution to developing solutions with CodeIgniter MVC.

Who is this book for?

This book is written for PHP developers who wish to learn how to use the CodeIgniterMVC framework for application development. No experience of CodeIgniteris necessary, as this book is for beginning MVC development.

What you will learn

  • Install CodeIgniter and get acquainted with CodeIgniter resource directories
  • Making your first web application
  • Definiing your own CodeIgniter libraries
  • Issuing AJAX calls of CodeIgniter controller methods
  • Learning about controllers, helpers, and their usage
  • Understandingthe CodeIgniter naming conventions
  • Accessing CodeIgniter-assigned databases and other resources from your helpers
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 23, 2013
Length: 192 pages
Edition : 1st
Language : English
ISBN-13 : 9781849694704

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : Sep 23, 2013
Length: 192 pages
Edition : 1st
Language : English
ISBN-13 : 9781849694704

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 142.97
CodeIgniter Web Application Blueprints
$48.99
Programming with CodeIgniter MVC
$38.99
CodeIgniter 2 Cookbook
$54.99
Total $ 142.97 Stars icon

Table of Contents

7 Chapters
Getting Started Chevron down icon Chevron up icon
Configurations and Naming Conventions Chevron down icon Chevron up icon
Controller Usage and Scope Chevron down icon Chevron up icon
Libraries Chevron down icon Chevron up icon
Helpers Chevron down icon Chevron up icon
Models Chevron down icon Chevron up icon
Views Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Half star icon Empty star icon Empty star icon Empty star icon 1.8
(5 Ratings)
5 star 0%
4 star 0%
3 star 20%
2 star 40%
1 star 40%
Eric D. Brown Mar 04, 2014
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
I took a chance on this book and I'm not that happy that I did. This book provides very little in the way of 'new' examples and definitely stays away from any in-depth discussions of CodeIgniter. There's nothing in this book that you can't find on the CI website.
Amazon Verified review Amazon
alex3410 Jan 12, 2018
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
First impressions are the information is good but the formatting is really really poor - code sections have not been formatted for print so lines run on to multiple lines making it hard to readNo spacing between sections of code also make it hard to read with it all forming huge blocks of textFinally you are presented with complete code samples explained with comments within the code rather then separate sections - these comments are not immediately obvious & again run over causing confusion as to if the text is part of the comment or codeIt’s annoying because the topics complex enough as it is without struggling with poor layoutUpdate : finished the book, poor formatting continues throughout & makes it harder to understand the examples, writing in places is poor which again makes it harder to understand.That being said it’s got useful information in there & worth reading if only because the number of books on CI development are slim
Amazon Verified review Amazon
Ola Klingberg Sep 12, 2014
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book might become worthy of three or ever four stars, once it’s finished, but this sloppily proof-read draft should not have been published. I’m at page 45, and I’m giving up now.Both the general text and the code examples are so littered with typos and misused words that they are often difficult to make sense of.The text reads “a single comma” when they mean “single quotes.” It says “The Boolean and contacts” when they mean “Booleans and constants.” The introduction to an example says that it “... creates a form for adding and editing a product” when in fact the example that follows is for a contact form that has nothing to do with any products. And the code often looks like this: function index () {// executed when referring to My_handlercontroller viaURLecho “Hello World”; }You have to look at that for a minute to figure out what is code and what is comment, since the lines have been muddled together.I’m thinking about requesting a refund, even though I’ve made some highlighting. This book was simply not ready to be sent to the printer.
Amazon Verified review Amazon
Dean Barker Mar 03, 2014
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
The php code is not formatted correctly and is very difficult to follow. New lines are not new lines and the comments merge with the actual code in one big messy block. Never buying another tech book from Kindle again. Would get a refund if its possible but its been too ling since I bought.
Amazon Verified review Amazon
Amazon Customer Oct 29, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Useless
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon