Welcome Guest, Not a member yet? Register   Sign In
Problems getting a simple form working....
#1

[eluser]Lee Mc[/eluser]
Hi,

I've put together a simple contact form using CI, but the problem is i'm not that familiar with CI or even PHP if i'm honest.

So I got this form mostly working, but can't figure out how to generate error messages on screen when my validation routine fails. Any ideas...?? I've found most other things in the documentation relatively straightforward, but the validation stuff isn't very clear...

Any help appreciated (I start my day job in 7 hours...)

Here's my controller code if that helps:

class Rsvp extends Controller {
function Rsvp()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
}

function index()
{
$rules['firstname'] = "callback_firstnamechk";
$rules['surname'] = "required";

$this->validation->set_rules($rules);

if ($this->validation->run() == FALSE)
{
$this->load->view('containerrsvp');
}
else
{
$this->load->library('email');
$this->email->from('Wedding Site', 'Guest');
$this->email->message($msg);
$this->email->send();
$this->load->view('containerrsvpthanks');
}
}

function firstnamechk($str)
{
if ($str == NULL)
{
$this->validation->set_message('firstnamechk', 'You forgot to give us your &#xst;r');
return FALSE;
}
else
{
return TRUE;
}
}


Messages In This Thread
Problems getting a simple form working.... - by El Forum - 10-16-2007, 05:45 PM
Problems getting a simple form working.... - by El Forum - 10-16-2007, 05:56 PM
Problems getting a simple form working.... - by El Forum - 10-16-2007, 06:00 PM
Problems getting a simple form working.... - by El Forum - 10-16-2007, 06:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB