Welcome Guest, Not a member yet? Register   Sign In
Error message does not appears
#1

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);
            
    } 
" If I looks more intelligence please increase my reputation."
Reply
#2

http://php.net/manual/en/function.echo.php
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#3

(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.
" If I looks more intelligence please increase my reputation."
Reply
#4

And where is your form closing tag?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(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.
" If I looks more intelligence please increase my reputation."
Reply
#6

Your rule contains "Required". Try "required" (lower case).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB