Welcome Guest, Not a member yet? Register   Sign In
Organizing the Site!
#11

[eluser]Drew Barontini[/eluser]
Code:
class Contact extends Controller {
    
    function index() {
        
        // Validations
        $this->load->library('validation');
        $rules['name'] = "required";
        $rules['email'] = "required|valid_email";
        $this->validation->set_rules($rules);
        
          // Input and textarea field attributes
        $data['name'] = array('name' => 'name', 'id' => 'name');
        $data['email'] = array('name' => 'email', 'id' => 'email');
        $data['comments'] = array('name' => 'comments', 'id' => 'comments', 'rows' => 3, 'cols' => 40);

        // Checkbox attributes
        $data['graphic'] = array('name' => 'services[]', 'id' => 'graphic', 'value' => 'Graphic Design', 'checked' => FALSE);
        $data['web'] = array('name' => 'services[]', 'id' => 'web','value' => 'Web Design/Development', 'checked' => FALSE);
        $data['myspace'] = array('name' => 'services[]', 'id' => 'myspace','value' => 'Myspace Design', 'checked' => FALSE);
        $data['cms'] = array('name' => 'services[]', 'id' => 'cms','value' => 'CMS', 'checked' => FALSE);

        if ($this->validation->run() == FALSE) {
            
            $this->load->view('contact/contact_view', $data);
    
        } else {
            
            // Get POST data
            $name = $this->input->post('name');
            $email = $this->input->post('email');
            $comments = $this->input->post('comments');
            $services = "";

            foreach($this->input->post('services') as $value) {

                $services .= "$value\n";

            }

            $message = $name . " would like the following   services:\n\n" . $services . "\n\n". $name ." also said:\n" . $comments;

            // Set our email fields
            $this->email->from($email, $name);
            $this->email->to('[email protected]');
            $this->email->subject('Your services are requested!');
            $this->email->message($message);
            $this->email->send();

            //load our view file
            $this->load->view('contact/contact_success');

        }
    
    }
        
}


Messages In This Thread
Organizing the Site! - by El Forum - 05-17-2008, 12:06 PM
Organizing the Site! - by El Forum - 05-17-2008, 12:50 PM
Organizing the Site! - by El Forum - 05-17-2008, 04:37 PM
Organizing the Site! - by El Forum - 05-17-2008, 05:01 PM
Organizing the Site! - by El Forum - 05-17-2008, 05:10 PM
Organizing the Site! - by El Forum - 05-17-2008, 06:33 PM
Organizing the Site! - by El Forum - 05-17-2008, 07:17 PM
Organizing the Site! - by El Forum - 05-17-2008, 08:18 PM
Organizing the Site! - by El Forum - 05-17-2008, 08:38 PM
Organizing the Site! - by El Forum - 05-17-2008, 08:40 PM
Organizing the Site! - by El Forum - 05-17-2008, 09:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB