我下载准则Igniter 2.1.0,我接过rel=“nofollow”>tutorial 。
问题在于我试图以本《欧洲刑法》的形式提出:
http://localhost/CodeIgniter/index.php/news/create
the page is redirected to this URL:
http://localhost/CodeIgniter/index.php/news/localhost/CodeIgniter/index.php/news/create
我为改变路线提出了许多办法。 php,但它没有工作。 我如何确定这一点?
route.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 ;
This is the code for the form page:
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 notice that when the form page when the page is loaded, below code segment will executed, however, the else segment never got changes to execute.
if ($this->form_validation->run() === FALSE)
{
$this->load->view( templates/header , $data);
$this->load->view( news/create );
$this->load->view( templates/footer );
}
This is the form page, nothing special, just call the create function shown above. create.php
<h2>Create a news item</h2>
<?php echo validation_errors(); ?>
<?php echo form_open( news/create ) ?>
<label for="title">Title</label>
<input type="input" name="title" /><br />
<label for="text">Text</label>
<textarea name="text"></textarea><br />
<input type="submit" name="submit" value="Create news item" />
</form>
This is the HTML for the form page:
<html>
<head>
<title>Create a news item - CodeIgniter 2 Tutorial</title>
</head>
<body>
<h1>CodeIgniter 2 tutorial</h1><h2>Create a news item</h2>
<form action="localhost/CodeIgniter/index.php/news/create" method="post" accept-charset="utf-8">
<label for="title">Title</label>
<input type="input" name="title" /><br />
<label for="text">Text</label>
<textarea name="text"></textarea><br />
<input type="submit" name="submit" value="Create news item" />
</form><strong>©2012</strong>
</body>
</html>
当我发布<条码>新项目条码>纽吨时,URL改为
http://localhost/CodeIgniter/index.php/news/localhost/CodeIgniter/index.php/news/create
and page shows 404 Pages Not Found