php - codeigniter insert to mysql with external variable -
i sending form in $post
, means jquery post, file called: register.php
now variable called "name" ... in register.php code:
<?php include "external.php"; $ci->load->database(); $fullname=$_request['name']; $data = array( 'full_name' => $fullname ); $ci->db->insert('tbl_users', 'full_name'=>''); if( $_request["name"] ) { $name = $_request['name']; echo "welcome ". $name; } ?>
the external.php load codeigniter.
request name want insert db...
the code inserting db [full_name table] empty name.. , got problem:
a php error encountered
severity: warning
message: mysql_real_escape_string() expects parameter 2 resource, boolean given
filename: mysql/mysql_driver.php
line number: 314
how can insert $_request["name"]
database ?
in view
<?php echo form_open_multipart(base_url().'moderator/b2bcategory/insertname'); ?> <div class="box-body"> <div class="row"> <div class="col-xs-6"> <div class="form-group"> <label for="txtcatname">title of category :</label> <input type="text" name="txtname" class="form-control" id="txtname" placeholder="category name " required="required"> </div> </div>
in controller
public function insertname() { $this->load->helper(array('form', 'url')); $this->load->view('moderator/templates/header'); $this->load->view('moderator/templates/sidebar'); if ($this->input->post('selsub')) { $data = array('db_name' => $this->input->post('name')); $this->b2bcategory_model->form_insert($data); } }
in model
public function form_insert($data){ $this->db->insert('jil_category', $data); }
i sure wil you
Comments
Post a Comment