Welcome Guest, Not a member yet? Register   Sign In
Create News Item Tutorial
#1

[eluser]davy_yg[/eluser]

I did create news item tutorial from the help guide.

At the end I point my url to:

http://localhost/News/index.php/news/create


404 Page Not Found

The page you requested was not found.


Why is it? Do I have to fill in something in the database first ?
#2

[eluser]PravinS[/eluser]
can you please paste "create" controller code here
#3

[eluser]davy_yg[/eluser]

I don't have a controller name create only a file name create.php

views/news/create.php

Code:
<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;
#4

[eluser]jairoh_[/eluser]
sir you must have a controller.

in you controller ex.

controllername.php
Code:
&lt;?php
class Controllername extends CI_Controller {
           function index () {
                  $this->load->view( 'news/create' );
            }
}
and access it using
http://localhost/News/index.php/controllername
or
http://localhost/News/controllername



hope this helps.
#5

[eluser]davy_yg[/eluser]

controllers/pages.php

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

I try : http://localhost/News/index.php/pages/create


404 Page Not Found

The page you requested was not found.




Theme © iAndrew 2016 - Forum software by © MyBB