[eluser]Unknown[/eluser]
For some reason this code is inserting into my DB twice sometimes. Not all the time though.
Code:
<?php
class Clock extends Controller {
function Clock()
{
parent::Controller();
$this->load->model('Local_Functions');
}
function index()
{
if ($this->session->userdata('logged_in') != '1')
{
$data['status'] = 'You are not autorized to view this page.';
}
else
{
$data['status'] = 'You have reached this page in error.';
}
$this->layout->buildPage('member_view', $data);
}
function timein()
{
if ($this->session->userdata('logged_in') != '1')
{
$data['status'] = 'You are not autorized to view this page.';
}
else
{
$data['nlinks'] = $this->Local_Functions->getLinks();
$idata = array(
'user_id' => $this->session->userdata('user_id') ,
'time_entry' => time() ,
'in_out' => 1
);
$this->db->insert('time_clock', $idata);
$data['status'] = 'You have been clocked in.';
}
$this->layout->buildPage('member_view', $data);
}
function out()
{
if ($this->session->userdata('logged_in') != '1')
{
$data['status'] = 'You are not autorized to view this page.';
}
else
{
$data['nlinks'] = $this->Local_Functions->getLinks();
$idata = array(
'user_id' => $this->session->userdata('user_id') ,
'time_entry' => time() ,
'in_out' => 0
);
$this->db->insert('time_clock', $idata);
$data['status'] = 'You have been clocked out.';
}
$this->layout->buildPage('member_view', $data);
}
}
?>
Any Suggestions?