Skip to content

Instantly share code, notes, and snippets.

<?php
class MY_Controller extends CI_Controller
{
public $data = array(); // Array to store data - passed to views.
protected $view_path = null; // Here to overide the view path if needed.
protected function __construct()
{
<?php
class Home extends MY_Controller {
public function index()
{
// Automatically the system will render this view: ./application/views/home/index.php
}
public function page_two()
# domain: phawk.co.uk & peteyhawkins.com
<VirtualHost *:80>
ServerName phawk.co.uk
ServerAlias www.phawk.co.uk www.peteyhawkins.com peteyhawkins.com
ProxyPass / http://localhost:9000/
ProxyPassReverseCookieDomain localhost your.domain
ProxyPreserveHost on
<Location />
ProxyPassReverse /
</Location>
<?php
class User_model extends Model {
function add_user($user_array)
{
// Insert the new user array into the users table
return $this->db->insert('users',$user_array);
}
<!doctype html>
<html lang="en">
<head>
<title>User login</title>
</head>
<body>
<?=form_open(current_url())?>
<p><?=form_label('Email')?>
<?php
function logout()
{
// Destroy the session
$this->session->sess_destroy();
// Take the user back to the home page
redirect('/');
}
<?php
$db['default']['hostname'] = "localhost"; // Keep this set to localhost unless you have the database runnning remotely.
$db['default']['username'] = "YOUR DB USER";
$db['default']['password'] = "YOUR DB PASS";
$db['default']['database'] = "YOUR DB NAME";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
<?php
// Change the libraries line as follows
$autoload['libraries'] = array('form_validation','database','session');
// Change the helper autoload to the following line
$autoload['helper'] = array('language','html','string','url','form','image','file');
<?php
class Users extends Controller {
function users()
{
parent::Controller();
$this->load->model('User_model');
}
<?php
$config[ 'no_validation' ] = array(
'auth/login',
'auth/logout',
'home'
);