[eluser]RyanH[/eluser]
[quote author="Seppo" date="1201166632"]Just checking a possible error...
Can you copy the controller code?[/quote]Sure, here it is:
Code:
<?php
class Contact extends Controller{
function Contact()
{
parent::Controller();
}
function index()
{
// Load the helpers for URLs and forms
$this->load->helper('url');
$this->load->helper('form');
// Load the library for validation
$this->load->library('validation');
$this->load->library('email');
// Set page information and load the view file
$data['title'] = "Contact";
$this->load->view('contact_view', $data);
// Set the validation rules
$rules['name'] = "required|trim";
$rules['email'] = "required|trim";
$rules['subject'] = "";
$rules['message'] = "required|trim";
$this->validation->set_rules($rules);
// Set the fields for all of the input fields in case someone enters something incorrectly
$fields['name'] = "Name";
$fields['email'] = "Email";
$fields['subject'] = "Subject";
$fields['message'] = "Message";
$this->validation->set_fields($fields);
// Run the validation and if it's not successful, return them to the registration page
// If the validation is successful, send the email
if($this->validation->run() == FALSE)
{
$this->load->view('contact_view');
} else {
$this->email->from($this->validation->email, $this->validation->name);
$this->email->to('[email protected]');
$this->email->subject($this->input->post('subject'));
$this->email->message($this->validation->message);
$this->email->send();
echo $this->email->print_debugger();
}
}
}
In case you want to see it, here's the view file (this isn't the final HTML, just enough to test the functionality):
Code:
<html>
<head>
<title><?=$title?></title>
Contact form:
<?=form_open('contact'); ?>
Name: <input type="text" name="name" value="<?=$this->validation->name;?>" /> <?=$this->validation->name_error;?>
<br />
Email: <input type="text" name="email" value="<?=$this->validation->email;?>" /> <?=$this->validation->email_error;?>
<br />
Subject: <select name="subject">
<option selected value="General Inquiry">General Inquiry</option>
<option value="Bug report">Bug Report</option>
<option value="Other">Other</option>
</select>
<br />
Message: <textarea name="message" rows="10" cols="40"><?=$this->validation->message;?></textarea> <?=$this->validation->message_error;?>
<br />
<input type="submit" name="submit" value="Send" />
<br /><br />
</body>
</html>
I should also note that the undefined property error is being generated on all of the fields (name, email, subject and message).
Thanks for your help!