diff --git a/application/controllers/Form.php b/application/controllers/Form.php index 67d5edd..6ca8937 100644 --- a/application/controllers/Form.php +++ b/application/controllers/Form.php @@ -1,19 +1,28 @@ load->model('Form_model'); } - public function submit() { + public function submit() + { if (!$this->session->userdata('logged_in')) { // If not logged in, redirect to login page redirect('users/login'); } + $form_data = json_decode($this->input->raw_input_stream, true); + $this->load->model('Form_model'); if ($this->Form_model->save_form($form_data)) { $response = array('status' => 'success', 'message' => 'Form submitted successfully.'); @@ -24,13 +33,13 @@ class Form extends CI_Controller { echo json_encode($response); } - public function view($form_id) { + public function view($form_id) + { $data['title'] = $this->Form_model->get_form_title($form_id); - if ($data['title'] === null) { show_404(); // Show 404 if form_id is invalid } - $this->load->view('templates/forms_ui',$data); + $this->load->view('templates/forms_ui', $data); } -} \ No newline at end of file +}