EllisLab text mark
Advanced Search
     
Undefined index
Posted: 05 September 2007 04:36 AM   [ Ignore ]
Joined: 2007-08-13
8 posts

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:

<?php 
$attributes1 
= array('name' => 'updateform');
echo 
form_open("?".$path.'misc',$attributes1); 
?>
<span id="spec-header">&nbsp;Resource <?php echo $put_in;?>&nbsp;</span><br />
    <
textarea name="tmpl_content" cols="100" rows="40">
        
<?php 
            
echo $file_details['file'][$look_up];
        
?> 
    
</textarea>
    <
br />
    <
input type="hidden" name="templatename" value="<?php echo $templatename;?>" />
    <
input type="hidden" name="templatefileid" value="<?php echo $tmpl_fileid; ?>" />
    <
input type="hidden" id="templateid" name="templateid" value="<?php echo $templateid ;?>" />
    <
input type="submit" name="updatetemplate" value="Update" class="submit0" />
    <
input type="submit" name="exporttemplate" value="Export Template" class="submit1" />
</
form

2) Controller

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.