Welcome Guest, Not a member yet? Register   Sign In
Undefined index
#1

[eluser]abbe01[/eluser]
I have bumped into an error as while I have 2 submit button within 1 form, which is update and export submit button. The form is sent to templates/misc for process. Below is my code in codeigniter
1) View:
Code:
<?php
$attributes1 = array('name' => 'updateform');
echo form_open("?".$path.'misc',$attributes1);
?>
<span id="spec-header">&nbsp;Resource : &lt;?php echo $put_in;?&gt;&nbsp;</span><br />
    &lt;textarea name="tmpl_content" cols="100" rows="40"&gt;
        &lt;?php
            echo $file_details['file'][$look_up];
        ?&gt;
    &lt;/textarea&gt;
    <br />
    &lt;input type="hidden" name="templatename" value="&lt;?php echo $templatename;?&gt;" /&gt;
    &lt;input type="hidden" name="templatefileid" value="&lt;?php echo $tmpl_fileid; ?&gt;" /&gt;
    &lt;input type="hidden" id="templateid" name="templateid" value="&lt;?php echo $templateid ;?&gt;" /&gt;
    &lt;input type="submit" name="updatetemplate" value="Update" class="submit0" /&gt;
    &lt;input type="submit" name="exporttemplate" value="Export Template" class="submit1" /&gt;
&lt;/form&gt;

2) Controller
Code:
function misc(){
            
$templateid = trim($_POST['templateid']);
            
if ($_POST['updatetemplate']){
    $this->Templates_Model->update_template();
    redirect($this->path."view/".$templateid);
    exit;    
}
if ($_POST['exporttemplate']){
    //echo "here";
    $this->export_template();    
}    
}
But, once I have 2 submit button and either one button I submit, it will give me error say undefined index updatetemplate(if i submit exporttemplate). What's wrong with the code? Can't have more than 1 submit button at one form? Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB