Welcome Guest, Not a member yet? Register   Sign In
from validation + email [solved]
#5

[eluser]wawer[/eluser]
I solve the problem. I make second controller function called send and now works fine. Now controller:

Code:
function kontact(){// loadning view with contact form
        $data['page_title'] = 'Kontakt';
        $data['page'] = 'kontact';    
        $this->load->view('index',$data);    
    }
    function send() {// sending mail
        $this->load->library(array('form_validation', 'email'));
        $this->load->helper('email');
        $this->form_validation->set_rules('title', 'Title', 'trim|required');
        $this->form_validation->set_rules('email', 'Email', 'trim|required');
        $this->form_validation->set_rules('content', 'Content', 'required');

        $data['page_title'] = 'Kontakt';
        $data['page'] = 'kontact';    

        if ($this->form_validation->run() == FALSE){
        $this->load->view('index',$data);
        }
        else{
            $this->email->from($this->input->post('email'));
            $this->email->to('[email protected]');
            $this->email->reply_to($this->input->post('email'));

            $this->email->subject($this->input->post('title'));
            $this->email->message($this->input->post('content'));
                $this->email->send();
                $data['page'] = 'succes';
                $data['info'] = 'Wysłano prawidłowo.';
                $this->load->view('index',$data);
        }
    }

The view:

Code:
<?=form_open('main/send', array('id' => 'kontact')); ?>
<?=validation_errors(); ?>
<strong for="kontact-1">Tytuł emaila</strong><br />
&lt;?=form_input(array('name'=>'title','size'=> '20','validation'=>'required')); ?&gt;<br />
<strong for="kontact-2">Twój email</strong><br />
&lt;?=form_input(array('name'=>'email','size'=> '20','validation'=>'email')); ?&gt;<br />
<strong for="kontact-3">Wiadomość</strong><br />
&lt;?=form_textarea(array('name'=>'content','rows'=>'10','cols'=>'50','validation'=>'required')); ?&gt;<br />
<p>&lt;input type="submit" value="Wyślij!"  /&gt;&lt;/p>
&lt;?=form_close(); ?&gt;

Thanks for help.


Messages In This Thread
from validation + email [solved] - by El Forum - 09-14-2009, 02:19 AM
from validation + email [solved] - by El Forum - 09-15-2009, 02:09 AM
from validation + email [solved] - by El Forum - 09-15-2009, 02:42 AM
from validation + email [solved] - by El Forum - 09-15-2009, 03:30 AM
from validation + email [solved] - by El Forum - 09-17-2009, 08:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB