Welcome Guest, Not a member yet? Register   Sign In
An Error Was Encountered
#1

(This post was last modified: 06-06-2015, 12:17 PM by rahulb.)

I wrote the below code for form validation. When a mandatory field is not entered then is shows proper message, but when I press F5 and resubmit my form then I get error "An Error Was Encountered - The action you have requested is not allowed.". How shall I remove this error? Below is my code. Thank you In advance

View:
Code:
<?php
                   $argument = array(
                                       'role'      =>  'form',
                                       'class'     =>  'form-horizontal form-groups-bordered',
                                       'method'    =>  'POST',
                                       'enctype'   =>  'multipart/form-data'
                                   );
                   echo form_open(base_url().'admin/add_department',$argument);
               ?>
                   <div class="form-group">
                       <label for="field-1" class="col-sm-3 control-label"><?php echo get_phrase('name'); ?></label>

                       <div class="col-sm-5">
                           <input type="text" name="name" class="form-control" id="field-1" value="<?php echo set_value('name'); ?>" required>
                       </div>
                   </div>

                   <div class="form-group">
                       <label for="field-ta" class="col-sm-3 control-label"><?php echo get_phrase('description'); ?></label>

                       <div class="col-sm-9">
                           <textarea name="description" class="form-control wysihtml5" id="field-ta" data-stylesheet-url="<?php echo base_url(); ?>assets/css/wysihtml5-color.css" required><?php echo set_value('description'); ?></textarea>
                       </div>
                   </div>

                   <div class="col-sm-3 control-label col-sm-offset-2">
                       <input type="submit" class="btn btn-success" value="Submit">
                   </div>
                   <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash();?>" />
               </form>

           </div>

config/form_validation.php
PHP Code:
$config = array(
 
                'department' => array(
 
                                   array(
 
                                           'field' => 'name',
 
                                           'label' => 'Name',
 
                                           'rules' => 'required'
 
                                        ),
 
                                   array(
 
                                           'field' => 'description',
 
                                           'label' => 'Description',
 
                                           'rules' => 'required'
 
                                        )
 
                                                     
               
); 

Controller
PHP Code:
if ($this->form_validation->run('department') == FALSE)
{
 
       $page_data['page_name'    'xxxx';
 
       $page_data['page_title'   'xxxx';
 
       $this->load->view('xxxx'$page_data);
}
 else if (
$this->form_validation->run('department') == TRUE)
{
 
       $this->department('create');

Reply


Messages In This Thread
An Error Was Encountered - by rahulb - 06-06-2015, 12:44 AM
RE: An Error Was Encountered - by Blair2004 - 06-06-2015, 10:07 AM
RE: An Error Was Encountered - by pdthinh - 06-06-2015, 11:25 AM
RE: An Error Was Encountered - by rahulb - 06-06-2015, 11:52 AM
RE: An Error Was Encountered - by Avenirer - 06-08-2015, 01:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB