Search code examples
phpcodeigniterform-helpers

Code not working after converted form tag into form_open in codeigniter


I changed my code as form tages to form_open methods. After changing the actions are not working as previous.I have enabled csrf protection too.

previous code;

   <form action="<?php echo site_url();?>/admin/user_screen" method ="post" enctype="multipart/form_data" name="form">
            <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">

   ............form contents..................

   </form>

new code;

<?php 
  $attributes= array('name'=>'form');
  echo form_open('admin/screen_flow',$attributes);
?>

.....form contents.....

<?php echo form_close();?>

Solution

  • Try

    use this form_open_multipart instead of form_open

    <?php echo form_open_multipart('admin/screen_flow', array('name' => 'form'));?>
    
    .....form contents.....
    
    <?php echo form_close();?>