Welcome Guest, Not a member yet? Register   Sign In
$_POST textarea in a form
#1

[eluser]elaniobro[/eluser]
I can't seem to get the textarea to post:

Code:
<?php
    class Email extends Controller
    {
    
        function Email()
        {
            parent::Controller();    
        }
        
        function index()
        {
            $this->load->view('email_view');    
        }
        
        function send()
        {
            $this->load->library('form_validation');
            
            //field name, error message, validation rules
            $this->form_validation->set_rules('contact-email', 'email', 'trim|required|valid_email');
            $this->form_validation->set_rules('contact-fullName', 'full name', 'trim|required|min_length[5]');
            
            if($this->form_validation->run() == FALSE)
            {
                
                $this->load->view('email_view');
                
            }else{
                
                //validaiton has past, send e-mail
                $fullName = $this->input->post('contact-fullName');
                $email = $this->input->post('contact-email');
                $subject = $this->input->post('contact-subject');
                $body = $this->input->post('contact-body');
            
                $config = Array(
                            'protocol' => 'sendmail',
                            'smtp_host' => 'smtp.example.com',
                            'smtp_port' => 143,
                            'smtp_user' => '[email protected]',
                            'smtp_pass' => 'test'    
                                );
                $this->load->library('email');
    
                $this->email->from($email, $fullName);
                $this->email->to('[email protected]');            
                $this->email->subject($subject);
                $this->email->message($body);
                
                $this->load->library('email', $config);
                $this->email->set_newline("\r\n");
                
                if($this->email->send())
                {
                    $this->load->view('emailSucess_view');    
                }else{
                    
                    show_error($this->email->print_debugger());    
                    
                }            
                
            }
            
            

        }
    }
?>

view:
Code:
<div class="popup-container" id="contact-container">
                        <div class="watermark">
                            &lt;?=img(array('src'=>'img/footer/contact_a.png','alt'=>'contact'));?&gt;
                        </div>
                        <div class="close">
                            &lt;?= anchor('',
                                        img(array(
                                                  'src'=>'img/nav/nav_close_a.gif',
                                                  'id'=>'contactBack',
                                                  'border'=>'0',
                                                  'alt'=>'Close'
                                                  )
                                            ),
                                        array(                                          
                                              'onmouseover'=>'contactBack'.'.src='."'".base_url().'img/nav/nav_close_b.gif'."'".';'.'"',
                                              'onmouseout'=>'contactBack'.'.src='."'".base_url().'img/nav/nav_close_a.gif'."'".';'.'"'
                                              )
                                        );
                             ?&gt;
                        
                        </div>
                        <div class="clear"></div>
                            <div id="contact-form">
                                <div class="title">
                                    &lt;?= img(array('src'=>'img/footer/contact/trybuch_title_contact.gif','alt'=>'Contact Form'));?&gt;
                                </div>
                                &lt;?= form_open('email/send');?&gt;
                                
                                <p>&lt;input&gt;&lt;label class="contact-label">email</label></p>
                                <p>&lt;input&gt;&lt;label class="contact-label">full name</label></p>
                                <p>&lt;input&gt;&lt;label class="contact-label">subject</label></p>
                                <p>&lt;textarea name="contact-body" id="contact-body" rows="10"&gt;So tell me what is on your mind....&lt;/textarea&gt;&lt;/p>
                                &lt;?= form_submit('submit','Send');?&gt;
                                &lt;?= form_close();?&gt;
                                &lt;?= validation_errors('<p class="contact-error">');?&gt;
                            </div>
                    </div>

I keep getting the following message:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Email::$inputtext

Filename: controllers/email.php

Line Number: 34

Fatal error: Call to a member function post() on a non-object in /homepages/22/d233002287/htdocs/5/system/application/controllers/email.php on line 34

I tried chaning the controller to something like this:
$body = $this->textarea->post('contact-body');
#2

[eluser]elaniobro[/eluser]
but that is not working either. I've thoroughly read over the code, and there does not appear to be any syntax errors.

I also read over the form helper documentation and can't figure this guy out.

and lastly, I would like this not to go to a new page.

I have a contact form, that when clicked slides out using jQuery. This is where the form is. When you click send, it takes you to the email/send page, how can I prevent this from happening? So that all the validation and success view are loaded within this container div?
#3

[eluser]elaniobro[/eluser]
I resolved my issue
#4

[eluser]248creative[/eluser]
how?
#5

[eluser]elaniobro[/eluser]
Think it was syntax, I got rid of all the id's and names and removed the 'contact-' portion. I think they '-' was causing errors.




Theme © iAndrew 2016 - Forum software by © MyBB