Welcome Guest, Not a member yet? Register   Sign In
Form Validation
#1

[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...
#2

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

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

[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/
#5

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

[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)
#7

[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!!
#8

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

[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:
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB