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

[eluser]GND94MCA[/eluser]
Hi All, Here i am using user guide tutorial for Create news items, i have go through as define in user guide but when we input some data into form and submit, the url will show in the browser 'http://localhost/generater/index.php/news/localhost/?news/create' and 404 error will get. and the code process will given here see and help me.

1- Create the new view at application/views/news/create.php.

<h2>Create a news item</h2>

&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('news/create') ?&gt;

<label for="title">Title</label>
&lt;input type="input" name="title" /&gt;&lt;br />

<label for="text">Text</label>
&lt;textarea name="text"&gt;&lt;/textarea><br />

&lt;input type="submit" name="submit" value="Create news item" /&gt;

&lt;/form&gt;

2- News Controler class
class News extends CI_Controller {

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

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');
// $this->form_validation->run();

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');
}
}

}
3- Model class
class News_model extends CI_Model {

public function __construct()
{
$this->load->database();
}
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);
}

}
4- changes in routes.php

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

Any one help me.


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