Codeigniter how to set form action url using form_open helper function

Today, We want to share with you form_open in codeigniter.In this post we will show you form action in codeigniter, hear for $this- input- post not working codeigniter we will give you demo and example for implement.In this post, we will learn about How To Call Helper Function In Codeigniter View with an example.

Codeigniter form_open Form Helper Library Example

Controller Part

Codeigniter form_open Example :

<?php
    class User extends CI_controller{
    public function login()
    {
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->load->view('login_view'); 
    }
    }

View Part | login_view.php
Codeigniter form_open Example :

<?php echo validation_errors(); ?>

<?php echo form_open('user/login') ?>

    <label for="Id"> Username</label>
    <input type="input" name="username" />
    <br/>

    <label for="Password">Password</label>
    <input type="input" name="password" />
    <br/>

    <input type="submit" name="submit" value="Login" />

<?php echo form_close() ?>

CodeIgniter Form Helper

Functions of Form Helper

 echo form_open( 'Online/form' ); 

 $attributes = array('class' => 'online', 'id' => 'form'); 
 echo form_open('Online/form', $attributes);

 $hidden = array( 
     'type'  => 'text',
     'name'  => 'Maeve',
     'value' => '[email protected]',
     'class' => 'onlinehub '
 );
 echo form_open('Online/form', $attributes, $hidden);  

form_close():

echo form_open( 'Online/form' ); 

echo form_close(); 

form_open_multipart()

echo form_open_multipart( 'Online/form', $attributes);
 echo form_close(); 

form_hidden()

echo form_open();
 echo form_hide( ‘student’ , ‘Otis’);
 echo form_close(); 

form_input()

$input_data = array(
 'name' => 'tname',
 'id' => 'tname_id',
 'value' => 'ERIC '
 'readonly' => 'readonly'
 'placeholder' => 'Enter Your Name'
 ); 
 echo form_input($input_data); 

form_password()

$input_data = array(
 'name' => 'tname',
 'id' => 'tname_id',
 'value' => 'ERIC '
 'readonly' => 'readonly'
 'placeholder' => 'Enter Your Name'
 ); 
 echo form_input($input_data); 

form_upload():

$upload_data = array(
 'type' => 'file',
 'name' => 'upload_file'
 );
 echo form_upload($upload_data); 

form_textarea()

$rough_textarea = array(
 'name' => 'textarea',
 'rows' => 5,
 'cols' => 30
 );
 echo form_textarea($rough_textarea); 

form_dropdown():

  form_dropdown ([ $name = ‘ ‘ [, $options = array() [, $selected = array() [, $extra = ‘ ‘ ] ] ] ]); 

form_multiselect()

 echo form_label('Languages Known '. " ");
  $language = array(
    'LA' => 'LARAVEL',
    'PP' => "PHP",
    'AJ' => 'ANGULARJS',
    'VE' => 'VUEJS',
    'JS' => 'JavaScript',
  );
  
  echo " ".form_multiselect("Show[]", $language); 

form_fieldset()

echo form_open()
 $fieldset_data = array(
 'id' => 'student_info,
 'class' => 'student_detail'
 ); 
 echo form_fieldset(‘Student information, $fieldset_data);
 echo "<p>Enter your details here</p>";
 echo form_close(); 
 

I hope you get an idea about codeigniter form submit to database.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Laravel 6 Set Extra where condition Examples

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *