[eluser]Ivar89[/eluser]
I needed 2 submit buttons for my form, and I think I got it right but whenever I press the second submit button I let i reditrect to a page and give errors and I can't figure out whats wrong with it...
view:
Code:
<?php echo form_open('page/savesection'); ?>
<?php foreach ($sections as $section): ?>
<input type="radio" name="ID_Section" value="<?php echo $section->ID_Section ?>"><?php echo $section->strDescription ?><br />
<?php endforeach; ?><br />
<input type="hidden" name="ID_Page" value="<?php echo $ID_Page; ?>" />
<input type="submit" name="save" class="btn" value="Save" />
<input type="submit" name="save" class="btn" value="Add more sections" />
Controller:
Code:
function savesection()
{
if($_POST['save'] == 'Save')
{
$this->insert_model->Insert_Section_Data($_POST);
redirect('page');
}
else
{
$this->insert_model->Insert_Section_Data($_POST);
redirect('page/addsection');
}
return true;
}
Model:
Code:
function Insert_Section_data($data)
{
$data = array('ID_Page' => $data['ID_Page'], 'ID_Section' => $data['ID_Section']);
$this->db->insert('tblpagesection', $data);
return true;
}
The else is going wrong.
addsection controller:
Code:
function addsection($id)
{
$data['ID_Page'] = $id;
$this->db->where('ID_Page', $id);
$data['sections'] = $this->section_model->Get_Section_data($_POST);
$this->load->view('page/addsection', $data, FALSE);
}
when I click the submiot button with Add mor sections it gets me to the right pages but with these errors:
Quote:A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for page::addsection()
Filename: controllers/page.php
Line Number: 95
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: id
Filename: controllers/page.php
Line Number: 98
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: id
Filename: controllers/page.php
Line Number: 99
But I don't understand why it doesn't work when I go from page: savesection to addsection(redirect)
but When I just click on menu addsection it DOES work..and I dont get any errors..
any help? or suggestion to do this better