Skip to content

Instantly share code, notes, and snippets.

<?php
$parent_path = dirname( $_SERVER['DOCUMENT_ROOT'] );
define('SHAREDPATH', $parent_path . '/shared/');
// Runs this function when the page loads
$(document).ready(structureTabs);
function structureTabs()
{
// Insert a list to hold the tab buttons
$('#tabs').prepend('<ul id="tabbtns"></ul>');
// Split the content up, starting with each h2 and all other content until the following h2 comes.
$('#tabs h2').each(function(index){
<?php
class Users_model extends MY_Model
{
public function __construct()
{
parent::__construct();
/* Set Table info */
<?php
switch( $_SERVER['HTTP_HOST'] )
{
// Local Site
case 'local.ci.com':
define('SITE', 'local');
break;
// Development Site
<?php
function login()
{
// Set required fields
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE)
{
<?php
if ($this->session->userdata('user_id'))
{
echo 'Hello user '.$this->session->userdata('user_id');
echo ' '.anchor('users/logout','Logout').'<br />';
echo anchor('/privatepage','Private page');
}
else
{
<?php
class Privatepage extends MY_Controller {
function __construct()
{
parent::__construct();
}
function index()
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends Controller
{
function MY_Controller()
{
parent::Controller();
$this->auth_logged_in();
<!doctype html>
<html lang="en">
<head>
<title>User registration</title>
</head>
<body>
<?=form_open(current_url())?>
<p><?=form_label('first name')?>
<?php
class User_model extends Model {
function add_user($user_array)
{
return $this->db->insert('users',$user_array);
}
}