CodeIgniter 2.1.0을 다운로드하고 CodeIgniter 2.1.0에서 tutorial을 따랐습니다. 나는이 URL에서 양식을 제출하려고 할 때URL 리디렉션이 작동하지 않는 이유는 무엇입니까?
문제는 :
페이지가이 URL로 리디렉션됩니다http://localhost/CodeIgniter/index.php/news/create
: 나는 route.php을 변경하는 방법은 여러 가지 피곤
http://localhost/CodeIgniter/index.php/news/localhost/CodeIgniter/index.php/news/create
하지만 작동하지 않습니다. 이 문제를 어떻게 해결할 수 있습니까 ??
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';
이 폼 페이지에 대한 코드입니다
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');
}
}
나는 페이지가로드 될 때 때 양식 페이지, 다음 코드 세그먼트가 실행됩니다 통지 그러나, else 세그먼트는 절대로 실행되도록 변경되지 않았습니다.
if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $data);
$this->load->view('news/create');
$this->load->view('templates/footer');
}
이것은 양식 페이지이며 특별한 것은 아니며 위의 작성 기능을 호출하십시오. 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>
이 폼 페이지의 HTML입니다 :
<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>
그리고 나는 create new item
버튼을 누르면 URL이
http://localhost/CodeIgniter/index.php/news/localhost/CodeIgniter/index.php/news/create
페이지로 변경 보기 : 404 Pages Not Found
양식의 '조치'는 무엇입니까? 나는 당신이'form_open()'을 사용하고 있다는 것을 알고 있지만, 단지 유머와 HTML 출력을 확인한다. –
양식은 뉴스 제목과 뉴스 본문이 포함 된 데이터베이스에 새 뉴스를 삽입하는 것입니다. – qkzhu
모든 양식에'action' 속성이 있습니다. HTML 출력에 그 값이 무엇인지 묻습니다. –