google_forms/application/controllers/New_form.php

29 lines
930 B
PHP
Raw Permalink Normal View History

2024-07-12 11:50:41 +00:00
<?php
2024-08-09 12:04:48 +00:00
2024-07-12 11:50:41 +00:00
class New_form extends CI_Controller
{
2024-08-09 12:04:48 +00:00
public function create_form()
{
2024-07-19 10:46:18 +00:00
if (!$this->session->userdata('logged_in')) {
// If not logged in, redirect to login page
redirect('users/login');
}
2024-08-09 12:04:48 +00:00
2024-07-12 11:50:41 +00:00
$data['title'] = 'Form Details';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('description', 'Description', 'required');
2024-08-09 12:04:48 +00:00
if ($this->form_validation->run() === false) {
2024-07-12 11:50:41 +00:00
$this->load->view('templates/header');
2024-07-23 12:54:27 +00:00
$this->load->view('templates/form_title', $data);
2024-07-12 11:50:41 +00:00
$this->load->view('templates/footer');
} else {
$this->load->model('create_model');
2024-07-23 12:54:27 +00:00
$form_id = $this->create_model->details(); // Get the new form_id
2024-08-09 12:04:48 +00:00
2024-07-23 12:54:27 +00:00
// Redirect to the form view with the form_id
redirect('form/view/' . $form_id);
2024-07-12 11:50:41 +00:00
}
}
}