I'm using codeigniter's MVC to build a form where logged in users can post questions.
I am using a form that allows logged in users to insert data in a mysql table called Questions (table structure is shown below).
Questions table
______________________________________________
| id | User id | description | category |
|---------------------------------------------|
|1 | 22 | Car parts | 12 |
|---------------------------------------------|
|2 | 54 | Car parts | 8 |
|---------------------------------------------|
|3 | 112 | Car parts | 11 |
|_____________________________________________|
Once a user submits the form, the user's id and category_id (from the table below "users table") is inserted into the questions table above
Users table
___________________________________
| id | User id |category_id |
|-------------------------------
|1 | 22 | 12 |
|------------------------------ |
|2 | 54 | 54 |
|---------------------------- |
|3 | 112 | 8 |
|_________________________________|
My controller page code
$this->load->model('questions_page');
$data['page_detail'] = $this->questions_page->get_business_page_by_pid($page_id);
if ($this->form_validation->run() == false || $form_validation == false)
{
$data['form_value'] = array(
'country' => $this->input->post('description'),
'street_address' => $this->input->post('street_address'),
'post_code' => $this->input->post('post_code'),
);
$this->load->view('template', $data);
}
This is my View page
<input type="text" name="post_code" value="<?= $form_value['description'] ?>">
<?php echo form_error("description"); ?>
<input type="text" name="post_code" value="<?= $form_value['street_address'] ?>">
<?php echo form_error("street_address"); ?>
<?php // I gathered some info from the users table below which needs to be inserted into the questions table
////////////////////////////
///////////////////////////
$page_detail->category_id;
////////////////////////////
///////////////////////////
?>
My problem I have data in the view page in the last line ( $page_detail->category_id; ) that I'd like to transfer to the controller page so I can insert it in the mysql table using the $data['form_value'] = array(); as shown in the controller page.
How do I do this?
Is transferring data from the view to controller safe?
Thanks in advance