I am making a HTTP request to a url, in which the data is getting post in request headers, but when I am fetching it in controller using the $this->input->post
, it is showing blank.
Angularjs code :
//Code to send email of quiz results
$scope.processresult=function(){
$http({
method:"POST",
url:"http://localhost/quizci/admin/sendresultemail/",
data:{
"riskscore":$scope.datascore
},
})
.success(function (data) {
if (!data.success) {
// if not successful, bind errors to error variables
$scope.errorName = data.errors.name;
$scope.errorSuperhero = data.errors.superheroAlias;
}
else {
// if successful, bind success message to message
$scope.message = data.message;
}
});
}
Controller Function :
function sendresultemail(){
$from_email = "test@test.com";
// $to_email = $this->input->post('email');
$to_email = "abc@gmail.com";
$this->load->model('user_model');
// $result = $this->user_model->get_user_by_id($this->session->userdata($sess_array['id']));
echo "risk score =".$this->input->post('riskscore');
exit;
//Load email library
$this->load->library('email');
$this->email->from($from_email, 'ERMS');
$this->email->to($to_email);
$this->email->subject('Email Test');
$this->email->message($_POST);
//Send mail
if($this->email->send()){
$this->session->set_flashdata("email_sent","Email sent successfully.");
}
else {
$this->session->set_flashdata("email_sent","Error in sending Email.");
$this->load->view('admindash');
}
}
you can see the data in request payload, but in the response it is showing blank