CodeIgniter_Gforms/application/controllers/Forms.php

33 lines
857 B
PHP
Raw Normal View History

2024-07-11 13:04:55 +00:00
<?php
class Forms extends CI_Controller
{
public function create(){
//check login
if(!$this->session->userdata('logged_in')){
redirect('users/login');
}
2024-07-12 09:55:29 +00:00
$data['title'] = 'Create Form';
2024-07-12 06:21:27 +00:00
$this->load->view('templates/header');
2024-07-11 13:04:55 +00:00
$this->load->view('forms/create', $data);
$this->load->view('templates/footer');
}
2024-07-12 06:21:27 +00:00
public function submit_form() {
$formData = $this->input->post('formData');
$decodedData = json_decode($formData, true);
// Process the form data here
// Example: Save the form data to the database
$this->load->model('Form_model');
2024-07-12 09:55:29 +00:00
2024-07-12 06:21:27 +00:00
$this->Form_model->save_form_data($decodedData);
echo json_encode(['status' => 'success', 'message' => 'Form data submitted successfully']);
}
2024-07-11 13:04:55 +00:00
}