• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about submission form to database

#2
I would recommend you going through the html form at first.

Like,

View : 

PHP Code:
<form action="POST" method="<?php echo base_url('/your_controller/lets_post_it');?>">
 
  <input type="text" name="member_name" class="blabla" placeholder="Please Insert Your Name"/>
 
  <input type="text" name="member_username" class="blabla" placeholder="Please Insert Your Username"/>

<
buttonSend it </button>

</
form


Controller 

PHP Code:
public function lets_post_it() {

 
 $name $this->input->post('member_name);  //first retrieve from inputs
  $username = $this->input->post('
member_username');

  $data = array(
     '
member_name'=> $name,  // then match with your database
     '
member_username' => $username
);

   $this->load->model('
My_Model');
  $result = $this->My_Model->upload_it($data);  // and send it to model

  if($result){
      $this->session->set_flashdata('
success', 'Data has been inserted successfully');
      redirect($SERVER['
HTTP_REFERER']);
}


MODEL

PHP Code:
public function upload_it($data){
 
 
   $query 
$this->db->insert('table_name'$data);

 
  return $query;

Reply


Messages In This Thread
RE: Question about submission form to database - by demyr - 08-07-2019, 02:19 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.