CodeIgniter Forums
Form Validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Form Validation (/showthread.php?tid=27364)

Pages: 1 2


Form Validation - El Forum - 02-08-2010

[eluser]parabolic151[/eluser]
Hey, I am having an issue with validating my form, for some reason the form_validation library is not loading...

this is my Email Controller:

Code:
<?php

class Email extends Controller
{
            function __construct(){
                parent::Controller();
            }
            function index()
            {
            $this->load->view('contact');
            $this->load->library('form_validation');
            }
            
            function send()
            {
    
                
                //Field name error message
                $this->load->form_validation->set_rules('name', 'Name', 'trim|required');
                $this->load->form_validation->set_rules('message', 'Message', 'required');
                $this->load->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email');
                
                if($this->form_validation->run()==FALSE)
                {
                $this->load->view('contact');
                }
                else
                {
                    //validation has passed
                    $name= $this->input->post('name');
                    $email= $this->input->post('email');
                    
                    
                    $this->load->library('email');
                    $this->email->set_newline("\r\n");
                    
                    $this->email->from('[email protected]', $email);
                    $this->email->to('[email protected]');
                    $this->email->subject($subject);
                    $this->email->message($message);
                    
                    $path = $this->config->item('server_root');
                    
                    
                    if($this->email->send())
                    {
                        echo'your message has been sent yoooo!';
                    }
                    else
                    {
                        show_error($this->email->print_debugger());
                    }
                }
                
                
            }
}


This is the error message that comes up when i try to use the form..

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$form_validation

Filename: controllers/email.php

Line Number: 24


if you want to see MY SITE it is the contact section I am having issues with...


Form Validation - El Forum - 02-08-2010

[eluser]maria clara[/eluser]
what code is in the line 24??


Form Validation - El Forum - 02-08-2010

[eluser]parabolic151[/eluser]
it is referring to : $this->load->form_validation->set_rules('name', 'Name', 'trim|required');


Form Validation - El Forum - 02-08-2010

[eluser]maria clara[/eluser]
[quote author="parabolic151" date="1265704203"]it is referring to : $this->load->form_validation->set_rules('name', 'Name', 'trim|required');[/quote]


can you try this:

Code:
$this->form_validation->set_rules('name', 'Name', 'required');

and yo check this thread... http://ellislab.com/forums/viewthread/47592/


Form Validation - El Forum - 02-08-2010

[eluser]tomcode[/eluser]
You load the library only in the method index(), put the call into the constructor or the send method.


Form Validation - El Forum - 02-08-2010

[eluser]theprodigy[/eluser]
Quote:You load the library only in the method index(), put the call into the constructor or the send method.
and, once you have moved the loading of the library to the constructor, make sure you change your rule setting to:
Code:
$this->form_validation->set_rules('name', 'Name', 'required');
instead of:
Code:
$this->load->form_validation->set_rules('name', 'Name', 'required');
(remove the "load" section)


Form Validation - El Forum - 02-09-2010

[eluser]parabolic151[/eluser]
ok thanks, that fixed the problem, now a bunch of other Errors show up. But hey, the validation works now. Thank you for your Help!!


Form Validation - El Forum - 02-09-2010

[eluser]theprodigy[/eluser]
what other errors?


Form Validation - El Forum - 02-09-2010

[eluser]parabolic151[/eluser]
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: subject

Filename: controllers/email.php

Line Number: 46

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: message

Filename: controllers/email.php

Line Number: 47

A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)

Filename: libraries/Email.php

Line Number: 1652

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1795

A PHP Error was encountered

Severity: Warning

Message: fgets() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1818

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1795

A PHP Error was encountered

Severity: Warning

Message: fgets() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1818

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1795

A PHP Error was encountered

Severity: Warning

Message: fgets() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1818

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1795

A PHP Error was encountered

Severity: Warning

Message: fgets() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1818

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1795

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1795

A PHP Error was encountered

Severity: Warning

Message: fgets() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1818

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /customers/pdbmedia.com/pdbmedia.com/httpd.www/system/libraries/Exceptions.php:166)

Filename: codeigniter/Common.php

Line Number: 356

An Error Was Encountered
The following SMTP error was encountered: 110 Connection timed out
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:


Form Validation - El Forum - 02-09-2010

[eluser]maria clara[/eluser]
can you post the code that pertains those error??