Advertisement
VladimirsBudkins

Антон Привалов CI Form reset

Jun 3rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. //controller
  3. class Ctrl extends CI_Controller {
  4.  
  5.     public function form() {
  6.         $post = $this->input->post();
  7.         $data = array(
  8.             'form_success_msg' => $this->session->flashdata('form_success')
  9.         );
  10.         if($post){
  11.             $this->load->library('form_validation');
  12.             $this->form_validation->set_rules();
  13.             if ($this->form_validation->run()) {
  14.                 $this->session->set_flashdata('form_success', 'Form sent');
  15.                 redirect(current_url());
  16.             }
  17.         }
  18.         $this->load->view('form',$data);
  19.     }
  20.    
  21. }
  22.  
  23. //form view
  24. <?php if($form_success_msg):?>
  25.     <?=$form_success_msg?>
  26. <?php endif?>
  27.  
  28. <?=form_open(current_url()); ?>
  29.     //your form here
  30. <?=form_close(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement