[eluser]n1ght3y3s[/eluser]
First thing; I am completely new to this so the problem is probably simple. I am just starting to learn to use codeigniter and thought I would start with a simple app that displays the number of sleeps till a certain event (kids love this).
Anyway I have a page that allows you to enter a description and a date which adds a new entry to a database and then it should go on to display a success page. This is very similar to the example on the tutorials page. Instead of getting my success page I am getting a blank page with the word 'undefined' in the top left corner. I enabled logging and the view looks to be loading without error. Any suggestions?
Here are some snippets of the code. If you need more let me know.
Model
Code:
public function set_events()
{
$data = array(
'id' => 0,
'desc' => $this->input->post('desc'),
'date' => $this->input->post('date'),
);
return $this->db->insert('events', $data);
}
Controller
Code:
public function create()
{
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = 'New Event';
$this->form_validation->set_rules('desc', 'Description', 'required');
$this->form_validation->set_rules('date', 'Date', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $data);
$this->load->view('events/create');
$this->load->view('templates/footer');
}
else
{
$this->events_model->set_events();
$this->load->view('events/success');
}
}
View: create.php
Code:
<?php echo validation_errors(); ?>
<?php echo form_open('events/create') ?>
<label for="desc">Description</label>
<input type="input" name="desc" /><br>
<label for="date">Date</label>
<input type="input" name="date"/>
<input type="submit" name="submit" value="Create Event" />
</form>
View: success.php
Code:
<h2>Success</h2><br>
Added new event