开发者社区> 问答> 正文

CodeIgniter表单提交出错!? 400 报错

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



然后我无论怎么输入或者不输入,都会进入myform.php,求各位大神讲解。谢谢~

展开
收起
爱吃鱼的程序员 2020-05-31 00:27:57 485 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    我记着需要加一些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也不行……

    2020-05-31 00:27:58
    赞同 展开评论 打赏
问答分类:
PHP
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载