[eluser]ChaosKnight[/eluser]
Hi, I started using CI yesterday and I'm loving it! There's only a few things that still bothers me... Firstly I find my own code very... very... very... slow... I don't know if it's only because I haven't enabled the cache yet. If someone can find the time to quickly look through my controller code, I'd really appreciate any help.
Contact controller
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Contact extends Controller
{
function index()
{
$this->load->helper(array('html','url','form'));
$this->load->library('form_validation');
$this->load->library('email');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$rules['name']="trim|required|xss_clean";
$rules['email']="trim|required|valid_email|xss_clean";
$rules['subject']="trim|required|xss_clean";
$rules['message']="trim|required|xss_clean";
$this->form_validation->set_rules($rules);
$data['page_title'] = 'Contact Us';
if ($this->form_validation->run() == FALSE)
{
$this->load->view('header',$data);
$this->load->view('nav');
$this->load->view('sidebar');
$this->load->view('contact');
$this->load->view('footer');
}
else
{
$this->email->from('[email address]','[name]');
$this->email->to('[email address]');
$this->email->subject($_POST['subject']);
$this->email->message($_POST['message']);
$data['title']='Contact Us';
$data['flash']=$this->email->send()?'The message has been recieved, thank
you!':'The message could not be sent, please try again.';
$this->load->view('header',$data);
$this->load->view('nav');
$this->load->view('sidebar');
$this->load->view('contact');
$this->load->view('footer');
}
}
}
/* End of Contact.php controller */
At the moment that code does nothing, I can't see why... The contact view is very basic, it's only a page with 4 fields (name, email, subject and message)
If someone can tell me why it's so slow and what I did wrong, I would be really grateful, thanks!
Oh and the email config page is where the tutorial told me to put it config/email.php
Thanks!