CodeIgniter Forums

Full Version: Error message does not appears
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Please cek my codes.  I wonder why <?php validation_errors(); ?> does not shows error message even when I leave galleries_name empty.

I expect it show this message: "Galleries Name Required".


<?php echo validation_errors(); ?>

views/addgalleries.php


PHP Code:
<?php echo form_open('Cpages/addgalleries');?>
                
                <?php echo validation_errors(); ?>
            
                <div class="widget-box">
                        <div class="widget-title"><h5>Galleries</h5></div>
                        
                        <br><br>
                        
                        <div style="margin-left: 20px;">
                        Galleries Name :  <input type="text" name="galleries_name"></input>
                        <input type="submit" class="edit" name="submit" value="ADD GALLERIES" />
                        </div>
                        
                        <br><br>
                                
                </div> 


controllers/Cpages.php

PHP Code:
public function addgalleries() { 
    
        
$this->form_validation->set_rules('galleries_name''Galleries Name''Required');
            
        if(
$this->form_validation->run() == FALSE)
        {
                        
            
$this->load->view('addgalleries');
            
        }
        else
        {
            
            
$data['galleriessuccess'] = 'Galleries Success has been Added';    
            
$this->Mpages->add_gallery();
            
$this->load->view('addgalleriessuccess'$data);
            
        }    
    
    } 


models/Mpages.php

PHP Code:
public function add_gallery()
    {
        
$data = array(
            
'galleries_name' => $this->input->post('galleries_name')                    
        );
        
        return 
$this->db->insert('galleries'$data);
            
    } 
(08-09-2016, 10:38 PM)albertleao Wrote: [ -> ]http://php.net/manual/en/function.echo.php

Thanks for the reference.  but I do not know how the reference should be applied in the program.
And where is your form closing tag?
(08-11-2016, 02:57 AM)InsiteFX Wrote: [ -> ]And where is your form closing tag?

I add the form closing tag.


views/addgalleries.php

PHP Code:
<?php echo form_open('Cpages/addgalleries');?>
                
                <?php echo validation_errors(); ?>
            
                <div class="widget-box">
                        <div class="widget-title"><h5>Galleries</h5></div>
                        
                        <br><br>
                        
                        <div style="margin-left: 20px;">
                        Galleries Name :  <input type="text" name="galleries_name"></input>
                        <input type="submit" class="edit" name="submit" value="ADD GALLERIES" />
                        </div>
                        
                        <br><br>
                                
                </div>    
            
                </form> 


I still have that same problem.  That the error message does not appears even when I leave the Gallery's name error.
Your rule contains "Required". Try "required" (lower case).