Codeigniter表格403

时间:2017-12-14 07:41:57

标签: php codeigniter http-status-code-403

我无法使用Codeigniter 3.1.6提交表单,因为我收到403 Forbidden

POST数据不会转到revise/updates。除了这个,我在其他页面上的表单工作得很好。我没有使用AJAX。

查看

<?=form_open('revise/updates');?>
   <input type="text" name="name" value="<?=$lead[0]['name'];?>">
   <input type="hidden" name="id" value="<?=$lead[0]['id'];?>">
   <input type="email" name="email" value="<?=$lead[0]['email'];?>">
   <input type="text" name="contact" value="<?=$lead[0]['phone_number'];?>">
   <input type="text" name="company" value="<?=$lead[0]['comp_name'];?>">
   <input type="text" name="va"  value="<?=$lead[0]['va'];?>" readonly>
   <input type="text" name="sales"  value="<?=$lead[0]['sales_name'];?>" readonly>
   <input type="text" name="service"  value="<?=$lead[0]['service_name'];?>" readonly>
   <textarea name="note"><?=$lead[0]['note'];?></textarea>
   <input type="hidden" name="opt" value="yes">
   <input type="hidden" name="cmd" value="1">
   <button type="submit" name="submit">Confirm</button>
<?=form_close();?>

控制器

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Revise extends VA_Controller {

   function __construct () {
      parent::__construct();
      $this->load->helper('form');
      $this->load->library('form_validation');
   }

    public function index($array)
    {
      $this->load->view('header');
      $this->load->view('update-lead',$array);
        $this->load->view('footer');
    }

   public function updates() {
      $this->form_validation->set_rules('name', 'Name', 'trim|required');
      $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
      $this->form_validation->set_rules('contact', 'Contact', 'trim|required');
      $this->form_validation->set_rules('company', 'Company Name', 'trim|required');
      $this->form_validation->set_rules('service', 'Service', 'trim|required');
      $this->form_validation->set_rules('va', 'vAmbassador', 'trim|required');
      $this->form_validation->set_rules('sales', 'Sales Person', 'trim|required');
      $this->form_validation->set_rules('note', 'note', 'trim');

      if($this->form_validation->run() == true) {
         echo "OK";
      }
      else {
         echo "Some Error";
      }
   }
}

我按照documentation

中提到的.htaccess文件

3 个答案:

答案 0 :(得分:0)

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

您必须从index.php

中删除/application/config/config.php条目

验证设置是否正确403 forbidden错误可能是由于.htaccess重写错误造成的。

答案 1 :(得分:0)

请尝试修改您现有的控制器,如下面的代码。

class Revise extends CI_Controller {

    function __construct () {
      parent::__construct();
      $this->load->helper('form');
      $this->load->library('form_validation');

      if(!isset($_SESSION["logged_in"]) && !isset($_SESSION["username"]) && $_SESSION["logged_in"] !== TRUE && $_SESSION["username"] !== 'example@example.com' ) 
      {
        redirect('/login');
      } 
}

答案 2 :(得分:0)

RewriteEngine on RewriteCond $ 1!^(index.php | resources | assets | robots.txt) RewriteCond%{REQUEST_FILENAME}! - f RewriteCond%{REQUEST_FILENAME}!-d