Hy everyone, i'm Stefano (a little italian dev 🙂 )
I've create a module for perfex.
This module insert a custom tab in projects tabs (admin project overview and customer project overview) where is present a custom form with few field.
In Administration mode i save and update the values in database, but in customer dashboard, when the customer click on save the action of the form (where i create a specified method for customer with redirect in some page) he redirect me in admin login page. probably for the permission for the customer.. but how to correct this problem?
the code is this.
Controller:
`public function save_client_test($project_id)
{
if ($this->input->post()) {
$success = $this->tests_model->save_test($this->input->post(null, false), $project_id);
redirect(site_url('clients/project/' . $project->id . '?group=project_test'));
}
}`
Models:
`public function save_test($data, $project_id)
{
// Check if the test content exists for this project;
$this->db->where('project_id', $project_id);
$tests = $this->db->get(db_prefix() . 'test_module')->row();
if ($tests) {
$this->db->where('id', $tests->id);
$this->db->update(db_prefix() . 'test_module', [
'name' => $data['name'],
'surname' => $data['surname'],
'mail' => $data['mail'],
]);
if ($this->db->affected_rows() > 0) {
return true;
}
return false;
}
$this->db->insert(db_prefix() . 'test_module', [
'name' => $data['name'],
'surname' => $data['surname'],
'mail' => $data['mail'],
'project_id' => $project_id,
]);
$insert_id = $this->db->insert_id();
if ($insert_id) {
return true;
}
return false;
return false;
} `
view:
`<?php echo form_open('tests/save_client_test/'.$project->id); ?>
<?php echo render_input('name', 'test_name',$name); ?>
<?php echo render_input('surname', 'test_surname',$surname); ?>
<?php echo render_input('mail', 'test_mail',$mail); ?>
</div>
<div class="col-md-8"></div>
</div>
</hr>
<div class="col-md-12">
<button type="submit" class="btn btn-info"><?php echo _l('save_test'); ?></button>
</div>
<?php echo form_close(); ?>`
Thanks a lot for the support