diff --git a/www/application/controllers/Search.php b/www/application/controllers/Search.php deleted file mode 100644 index c716fdc..0000000 --- a/www/application/controllers/Search.php +++ /dev/null @@ -1,14 +0,0 @@ -load->model('Search_Model'); - } - function index(){ - $this->load->view('search', NULL); - } - - -} diff --git a/www/application/controllers/User_Tweets.php b/www/application/controllers/User_Tweets.php index e5b6fb6..fc5b71c 100644 --- a/www/application/controllers/User_Tweets.php +++ b/www/application/controllers/User_Tweets.php @@ -18,4 +18,24 @@ public function index() { $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('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"); + } + + } + } diff --git a/www/application/models/User_Tweets_Model.php b/www/application/models/User_Tweets_Model.php index 369f512..66364e5 100644 --- a/www/application/models/User_Tweets_Model.php +++ b/www/application/models/User_Tweets_Model.php @@ -11,13 +11,10 @@ function getPosts(){ } function addTweet(){ - $this->load->helper('url'); - - $slug = url_title($this->input->post('title'), 'dash', TRUE); - + $this->load->helper('url'); $data = array( 'tweet' => $this->input->post('tweet'), - 'user_id' => 1 // UPDATE THIS WITH SESSION DATA + 'user_id' => 2 // UPDATE THIS WITH SESSION DATA ); return $this->db->insert('Tweets', $data); diff --git a/www/application/views/tweet.php b/www/application/views/tweet.php index 1355562..1d67d47 100644 --- a/www/application/views/tweet.php +++ b/www/application/views/tweet.php @@ -1,18 +1,9 @@ load->library('form_validation'); ?> - -

- -
-
-
-
Tweet
- - - -
-
-
-
+
Tweet
+ + + +
diff --git a/www/application/views/user.php b/www/application/views/user.php index 16a0d28..b23ef2d 100644 --- a/www/application/views/user.php +++ b/www/application/views/user.php @@ -1,6 +1,17 @@

My Tweets

+ + load->library('form_validation'); ?> + + + + + +
+ + +