Skip to content
Permalink
eb691ad8ea
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
49 lines (41 sloc) 1.52 KB
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User_Tweets extends CI_Controller {
function __Construct(){
parent::__Construct();
$this->load->database(); // load database
$this->load->model('User_Tweets_Model'); // load model
$this->load->helper('url');
}
public function index() {
// get posts based on user ID
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts()
$this->load->view('templates/header', NULL);
$this->load->view('templates/nav', NULL);
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer', NULL);
}
public function create(){
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('tweet', 'Tweet', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts()
$this->load->view('templates/header', NULL);
$this->load->view('templates/nav');
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer', NULL);
}
else
{
$this->User_Tweets_Model->addTweet();
redirect("/User_Tweets");
}
}
public function logout(){
$this->load->helper('url');
$this->session->sess_destroy();
redirect("/login");
}
}