CodeIgniter表单提交出错!? 400 报错
V层自己表单写好,检查错误如下:
<?=form_open('publish/submit'); ?>
<label for="title">标题</label>
<input name="title" type="text">
<label for="category">栏目</label>
<select name="category">
<option value="a">a</option>
<option value="b">b</option>
</select>
<script src="/ckeditor/ckeditor.js"></script>
<textarea id="editor1" name="contents"></textarea>
<script>CKEDITOR.replace( 'editor1' );</script>
<button type="submit">提交</button>
<?=form_close();?>
M层暂时没有加入
C层的:
<?php if ( ! defined("BASEPATH")) exit("No direct script access allowed");
class Publish extends CI_Controller {
public function index(){
$arr["page_tittle"] = "新闻发布页";
$this->load->view("templates/header",$arr);
$this->load->helper(array('form','url'));
$this->load->view("publish");
$this->load->view("templates/footer");
}
function submit(){
$this->load->library('form_validation');
if ($this->form_validation->run() == FALSE){
$this->load->view('myform');
}
else{
$this->load->view('formsuccess');
}
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
我记着需要加一些rules,否则form_validation->run()总是返回FALSE。
类似这样
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]');
@hsli你好,谢谢回答。
但是我不用这个方法,用检测输出$this->input->post也不行……