Restigniter How to sanitize inputs $this->input->post('key', true); # for single key post variable $this->input->post(null, true) # for the whole post object How to escape json properly echo json_encode($res, JSON_HEX_APOS|JSON_HEX_QUOT); # for escaping special characters such as single quotes