Welcome Guest, Not a member yet? Register   Sign In
Page not found error in create a news tutorial
#16

[eluser]soluicius[/eluser]
I have the same problem as above.
This is my htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.

    ErrorDocument 404 /index.php
</IfModule>


news_model.php:
Code:
&lt;?php

class News_model extends CI_Model {

public function __construct() {
  $this->load->database();
}

public function get_news($slug = FALSE) {
  
  if ($slug === FALSE) {
  
   $query = $this->db->get('news');
   return $query->result_array();
  }
  
  $query = $this->db->get_where('news',array('slug' => $slug));
  return $query->row_array();
}

public function set_news() {

$this->load->helper('url');

$slug = url_title($this->input->post('title'), 'dash', TRUE);

$data = array(
  'title' => $this->input->post('title'),
  'slug' => $slug,
  'text' => $this->input->post('text')
);

return $this->db->insert('news', $data);
}
}

?&gt;

news.php:
Code:
&lt;?php


class News extends CI_Controller {

public function __construct() {
  
  parent::__construct();
  $this->load->model('news_model');
}

public function index(){

$data['news'] = $this->news_model->get_news();
$data['title'] = 'News archive';

$this->load->view('templates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');
}

public function view($slug) {
$data['news_item'] = $this->news_model->get_news($slug);

if (empty($data['news_item'])) {
  show_404();
}

$data['title'] = $data['news_item']['title'];

$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}

public function create() {

$this->load->helper('form');
$this->load->library('form_validation');

$data['title'] = 'Create a news item';

$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'text', 'required');

if ($this->form_validation->run() === FALSE) {
  
  $this->load->view('templates/header', $data);
  $this->load->view('news/create');
  $this->load->view('templates/footer');

} else {
  $this->news_model->set_news();
  $this->load->view('news/success');
  }
}
}

Code:
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];

Code:
$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
$route['404_override'] = '';


Messages In This Thread
Page not found error in create a news tutorial - by El Forum - 01-31-2012, 04:33 AM
Page not found error in create a news tutorial - by El Forum - 01-31-2012, 05:53 AM
Page not found error in create a news tutorial - by El Forum - 01-31-2012, 10:54 PM
Page not found error in create a news tutorial - by El Forum - 01-31-2012, 11:31 PM
Page not found error in create a news tutorial - by El Forum - 03-10-2012, 10:13 PM
Page not found error in create a news tutorial - by El Forum - 03-10-2012, 10:29 PM
Page not found error in create a news tutorial - by El Forum - 03-11-2012, 01:38 AM
Page not found error in create a news tutorial - by El Forum - 03-15-2012, 06:08 PM
Page not found error in create a news tutorial - by El Forum - 03-15-2012, 06:57 PM
Page not found error in create a news tutorial - by El Forum - 03-15-2012, 07:32 PM
Page not found error in create a news tutorial - by El Forum - 03-15-2012, 07:54 PM
Page not found error in create a news tutorial - by El Forum - 03-16-2012, 12:42 AM
Page not found error in create a news tutorial - by El Forum - 03-16-2012, 07:16 AM
Page not found error in create a news tutorial - by El Forum - 05-02-2012, 11:09 PM
Page not found error in create a news tutorial - by El Forum - 10-31-2012, 05:30 PM
Page not found error in create a news tutorial - by El Forum - 12-13-2013, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB