我想验证 startdate 和 endate codeigniter,如果 stardate > enddate,不保存在我的数据库中,或者像这样显示错误消息我的控制器
function buat_lagi() {
if ($this->input->post('IDKategori')) {
$this->MKalender->addEvents();
$id = $_POST[IDKategori];
$this->session->set_flashdata('message', 'Agenda Pimpinan baru telah dibuat !');
redirect('admin/kalenderkategori/lihat/' . $id . '', 'refresh');
} else {
$data['title'] = "Tambah Agenda Pimpinan";
$data['kategori'] = $this->MKalenderKategori->getKategoriDropDown();
$data['main'] = 'admin/kalender/kalender_buat_lagi';
$this->load->vars($data);
$this->load->view('layout/dashboard');
}
}
我的模型是这样的
function addEvents() {
$data = array(
'IDKategori' => $this->input->post('IDKategori'),
'TanggalMulai' => $this->input->post('TanggalMulai'),
'TanggalAkhir' => $this->input->post('TanggalAkhir'),
'judul' => $this->input->post('judul'),
'konten' => $this->input->post('konten'),
'create_by' => $_SESSION['username'],
);
$this->db->insert('kalender', $data);
}
我的表格是这样的
<form action="<?= base_url(); ?>index.php/admin/kalender/buat_lagi/" method="post" enctype="multipart/form-data" name="form" id="form">
<?php
echo "<label for='ptitle'>Kegiatan / Lokasi :</label><br/>";
$data = array('class' => 'validate[required] text-input', 'name' => 'judul', 'id' => 'ptitle', 'size' => 80);
echo form_input($data);
echo "<p><label for='long'>Uraian Kegiatan / Keterangan / Catatan :</label><br/>";
$data = array('class' => 'validate[required] text-input', 'name' => 'konten', 'rows' => '13', 'cols' => '60', 'style' => 'width: 60%');
echo form_textarea($data) . "</p>";
echo "<p><label for='ptitle'>Waktu Mulai :</label><br/>";
$data = array('class' => 'validate[required] text-input', 'name' => 'TanggalMulai', 'id' => 'basic_example_1');
echo form_input($data) . "</p>";
echo "<p><label for='ptitle'>Waktu Akhir :</label><br/>";
$data = array('class' => 'validate[required] text-input', 'name' => 'TanggalAkhir', 'id' => 'basic_example_2', 'onblur' => 'function compareDate()');
echo form_input($data) . "</p>";
echo form_hidden('IDKategori', $this->uri->segment(4));
echo form_submit('submit', 'Tambah Even');
?>
<input type="button" value="Kembali" onClick="javascript: history.go(-1)" />
如何验证我的问题?