All posts tagged MVC

Cakephp: Creating and Sending Parameters Between Controller and View

Cakephp Step By Step Tutorial: We still wok with our first application at cakephp. But we will build controller and view better. Create parameters in controller and send it to view. It will make our application more flexible.

Create a new file books_controller.php within D:\xampp\htdocs\cakephp\app\controllers. Overwrite become like this:

<?php
    class BooksController extends AppController {
		
		var $Books = 'Books';
		var $uses=null;


       function index() {
		   
          $this->set('page_heading', 'Packt Book Store');       
          $book  = array (
                   'book_title'   => 'Object Oriented Programming  
                                                        with PHP5',
                   'author'     => 'Hasin Hayder',
                   'isbn'        => '1847192564',
                   'release_date' => 'December 2007'
                  );
		  
          $this->set($book);       
          $this->pageTitle = 'Welcome to the Packt Book Store!';
       }
    }
?>


Now create a folder books in side D:\xampp\htdocs\cakephp\app\views
And inside books create a file index.ctp. Rewrite with following code:

 <h2><?php echo $page_heading; ?></h2>
    <dl>
    <lh><?php echo $book_title; ?></lh>
    <dt>Author:</dt><dd><?php echo $author; ?></dd>
    <dt>ISBN:</dt><dd><?php echo $isbn; ?></dd>
    <dt>Release Date:</dt><dd><?php echo $release_date; ?></dd>
    </dl>

Point your browser to http://localhost:85/cakephp/books.

Send email with attachments in Codeigniter-series-3

We show how to send mail in codeigniter in http://learneveryday.net/php/framework/codeigniter/ci_series/sending-email-in-codeigniter/ . Today we will show how to send attachment. We just need to add two line of code to send attachment.
Bellow is the code.

<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
	function __construct()
	{
		parent::Controller();
	}
	
	function index() 
	{	

		

		$this->load->library('email');
		$this->email->set_newline("\r\n");
		
		$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
		$this->email->to('learneverydayTutorials@gmail.com');		
		$this->email->subject('This is an email test');		
		$this->email->message('It is working. Great!');
		
		
		$file =  './attachments/Info.txt';
		
		
		$this->email->attach($file);
		
		if($this->email->send())
		{
			echo 'Your email was sent, successfully.';
		}
		
		else
		{
			show_error($this->email->print_debugger());
		}
		
		
	}
}

?>
      

Continue reading →

Sending Email in CodeIgniter with gmail-series-2

Send mail in codeigniter is easy but using smtp by google is little tricky. Today we will show you how to send mail with smtp in gmail . Type the bellow code in your email.php in \application\controllers location. For us it is D:\xampp\htdocs\CodeIgniter\ci_series_2\application\controllers .

<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
	function __construct()
	{
		parent::Controller();
	}
	
	function index() 
	{	

		
		$config['protocol'] = 'smtp';
		$config['smtp_host'] = 'ssl://smtp.googlemail.com';
		$config['smtp_port'] = 465;
		$config['smtp_user'] = 'learneverydaytutorials@gmail.com';
		$config['smtp_pass'] = 'learneveryd@ytutorials';

	
		$this->load->library('email', $config);
		$this->email->set_newline("\r\n");
		
		$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
		$this->email->to('learneverydayTutorials@gmail.com');		
		$this->email->subject('This is an email test');		
		$this->email->message('It is working. Great!');
		
		
		if($this->email->send())
		{
			echo 'Your email was sent, successfully.';
		}
		
		else
		{
			show_error($this->email->print_debugger());
		}
	}
}

?>
      

Continue reading →

Sending Email in CodeIgniter-series-1

Sending mail in codeigniter is easy . Codeigniter has build in class on mail. You can easily configure it. Today we will see how to send mail . Latter tutorial we will see how to send mail in smtp.

Create a file email.php in D:\xampp\htdocs\CodeIgniter\ci_series_1\application\controllers
Write this code inside the email.php

<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
	function __construct()
	{
		parent::Controller();
	}
	
	function index() 
	{	
		$this->load->library('email');
		$this->email->set_newline("\r\n");
		
		$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
		$this->email->to('arifur.aiub@gmail.com');		
		$this->email->subject('This is an email test');		
		$this->email->message('It is working. Great!');
		
		
		if($this->email->send())
		{
			echo 'Your email was sent, successfully.';
		}
		
		else
		{
			show_error($this->email->print_debugger());
		}
	}
}

?>
      

Continue reading →

Setting up multiple applications with CodeIgniter

How can we use codeigniter framework directory to create multiple applications? Many times we need to run multiple codeigniter application . For all project we need the codeigniter system folder. If we copy the whole folder then it makes us trouble to update the codeigniter core. So that we use a unique codeigniter system for our multiple application. Lets see how we can do that.
The codeigniter structure is like this.
codeigniter file structure
Continue reading →