我现在使用codeigniter,我想根据复选框值添加或删除记录。
就像如果“发送零”然后删除,或者如果“发送一个”值然后添加。
这个任务怎么做?
<!-- Mail Menu Start -->
<div class="block">
<div class="titleSmal"><img src="<?= base_url(); ?>global/site/images/mailMenu.png" alt="" /></div>
<div class="content">
<form action="<?= base_url(); ?>mailinglist/send" method="post">
<fieldset class="form vote">
<legend> </legend>
<input id="e-mail" class="textBox med" name="ML_Email" value="<?= set_value('ML_Email')?>" /><span class="correct">accepted..</span><br />
<input id="subscription" type="radio" name="status" value="1" /><label for="answer1" class="label">subscription</label>
<input id="unsubscribe" type="radio" name="status" value="0" /><label for="answer2" class="label">unsubscribe</label><br />
</fieldset>
<input id="submit" type="submit" value="submit" class="button sml" />
</form>
</div>
</div><!-- Mail Menu End -->
控制器功能
function send() {
$this->form_validation->set_error_delimiters("<span class='incorrect'>", "</span>");
$this->form_validation->set_rules('ML_Email', 'البريد الالكتروني', 'trim|required|xss_clean|valid_email');
if ($this->form_validation->run() == false) {
$this->view('site/sending_error');
} else {
if($this->input->post('status')==1)
$this->mailinglist->send();
echo $this->db->last_query();
exit;
$this->view('theme/msg', $data);
}
}
}
模型函数
function send()
{
$this->db->set('ML_Email', $this->input->post('ML_Email'));
$this->db->set('status', $this->input->post('status'));
$this->db->set('ML_Date', date("l jS \o\F\ F Y H:i:s a"));
$this->db->insert('d_mailinglist');
return TRUE;
}