php - codeigniter CSRF error -


i'm trying use codeigniter csrf protection enabled. i've read answered solutions here , here didnt seem resolve issue. @ point "action requested not allowed" error solved, doesnt load form validation helper. throws 'unable load requested file: helpers/form_validation_helper.php` must have gone wrong?

here's controller file:

class home extends ci_controller {  function __construct(){     parent::__construct();     $this->load->helper('form'); }  public function index(){     $data['title'] = "home";     $data['main_content'] = 'frontend/index';      $this->load->view("frontend/includes/template", $data); }  public function contact(){     $data['title'] = "contact us";     $data['main_content'] = 'frontend/contact';     $this->load->view('frontend/includes/template', $data); }  //submit functions public function contact_submit(){     $send_clicked = $this->input->post('sub');     if(isset($send_clicked)){          $this->load->helper('date');         $this->load->helper('form_validation');          $this->form_validation->set_rules('name', 'name', 'trim|required|max_length[40]|xss_clean');         $this->form_validation->set_rules('email', 'email address', 'trim|required|max_length[50]|xss_clean');         $this->form_validation->set_rules('subject', 'subject', 'trim|required|max_length[100]|xss_clean');         $this->form_validation->set_rules('message', 'message', 'trim|required|max_length[1000]|xss_clean');          if ($this->form_validation->run() == false) {          } else {              $clean_name = $this->input->post('name');             $clean_email = $this->input->post('email');             $clean_subject = $this->input->post('subject');             $clean_message = $this->input->post('message');             $date = now();              $db_data = array(                 'name' => $clean_name,                  'email' => $clean_email,                  'subject' => $clean_subject,                  'message' => $clean_message,                  'date_posted' => $date                 );              print_r($db_data);         }     } }  public function page_missing(){     $data['title'] = "404 page missing";     $data['main_content'] = 'frontend/404';      $this->load->view("frontend/includes/template", $data); }  } 

here's configs of config.php made changes to:

$config['sess_cookie_name']     = 'qtd_sess'; $config['sess_expiration']      = 7200; $config['sess_expire_on_close'] = false; $config['sess_encrypt_cookie']  = true; $config['sess_use_database']    = true; $config['sess_table_name']      = 'qtd_sess'; $config['sess_match_ip']        = true; $config['sess_match_useragent'] = true; $config['sess_time_to_update']  = 300;  $config['cookie_prefix']    = ""; $config['cookie_domain']    = ""; $config['cookie_path']      = "/"; $config['cookie_secure']    = false;  $config['global_xss_filtering'] = true;  $config['csrf_protection'] = true; $config['csrf_token_name'] = 'csrf_test_name'; $config['csrf_cookie_name'] = 'csrf_cookie_name'; $config['csrf_expire'] = 7200; 

here part of view:

<!-- start contact form -->         <?php $attributes = array('class' => 'contact-form', 'id' => 'contact-form');          echo form_open('home/contact_submit', $attributes); ?>           <div class="form-group">             <div class="controls">               <input type="text" placeholder="name" name="name">             </div>           </div>           <div class="form-group">             <div class="controls">               <input type="email" class="email" placeholder="email" name="email">             </div>           </div>           <div class="form-group">             <div class="controls">               <input type="text" class="requiredfield" placeholder="subject" name="subject">             </div>           </div>            <div class="form-group">              <div class="controls">               <textarea rows="7" placeholder="message" name="message"></textarea>             </div>           </div>           <button type="submit" id="submit" name="sub" class="btn-system btn-large">send</button>           <div id="success" style="color:#34495e;"></div>         </form>         <!-- end contact form --> 

form validation not helper. library.

$this->load->helper('form_validation');// wrong  $this->load->library('form_validation');// correct. 

for more information see here


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -