i m trying to submit data using this code in codeigniter but can't submit data and create error.
error:POST http://localhost/managment/index.php/welcome/add 500 (Internal Server Error)
signupform is id of my sign up form which contain 6 fields and have a submit button
ajax i saved this file with .js extension
$(document).on("submit", "#signupform", function (e) {
e.preventDefault();
//var view_id=$("#id_hid").val();
//alert(view_id);
$.ajax({
type: "post",
data: $('#signupform').serialize(),
dataType: "JSON",
url: "../welcome/add",
success: function (data)
{
//var json=$.parseJSON(data);
alert(data);
}
});
});
controller
public function add() {
//$data=array();
$postData = array();
//prepare post data
$postData = array(
'username' => $this->input->post('username'),
'password' => $this->input->post('password'),
'email' => $this->input->post('email'),
'mobileno' => $this->input->post('mobileno'),
'address' => $this->input->post('address')
);
// //insert post data
$insert = $this->home_model->insert_form($postData);
$data['msg'] = "data insert successfully";
echo json_encode($data['msg']);
}
model
function insert_form($data)
{
$insert=$this->db->insert('emp',$data);
if($insert)
{
return $this->db->insert_id();
}
else
{
return false;
}
//echo json_encode($data);
}