数据未发布到phpmyadmin(带有codeigniter的建筑物)
正在调用requestform视图的控制器数据未发布到phpmyadmin(带有codeigniter的建筑物),php,codeigniter,phpmyadmin,Php,Codeigniter,Phpmyadmin,正在调用requestform视图的控制器 public function requestform(){ $this->load->helper('url'); $this->load->helper('form'); $this->load->library('form_validation'); $this->load->model('model_orders'); $data['title'] = 'Request Advice'; $t
public function requestform(){
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('model_orders');
$data['title'] = 'Request Advice';
$this->load->view('header', $data);
$this->load->view('requestform');
$this->load->view('footer');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('product_required', 'Product Required', 'required');
$this->form_validation->set_rules('problem_duration[]', 'Problem Duration', 'required');
$this->form_validation->set_rules('terms', 'Terms and Conditions', 'required');
if ($this->form_validation->run() == FALSE) {
$data['title'] = 'Request Advice';
$this->load->view('header', $data);
$this->load->view('requestform', $data);
$this->load->view('footer');
} else {
$order_array = array(
'id' => NULL,
'email' => $this->input->post('email'),
'product_required' => $this->input->post('product_required'),
'problem_duration' => implode(', ', $_POST['problem_duration'])
);
$insert_order = $this->model_orders->insert_order($order_array);
$this->load->view('homepage', $data);
}
}
public function accept_terms($value) {
if ($value == 'accept') {
return TRUE;
} else {
return FALSE;
}
}
请求表单视图:
<body>
<div id="body">
<?php
echo validation_errors();
echo form_fieldset('Email');
$data = array(
'name' => 'email',
'id' => 'email',
'value' => 'Type email address',
'maxlength' => '100',
'size' => '50',
'style' => 'width:250px',
);
$js = 'onClick="alert(\'Enter in details!\')"';
echo form_input($data, '', $js);
echo form_fieldset_close();
echo form_fieldset('Choose product required for advice (dropdown)');
$options = array(
'aloeverajuice' => 'Aloe Vera Juice',
'aloeveraskin' => 'Aloe Vera Skincare',
'aloeveragel' => 'Aloe Vera Gel',
);
echo form_dropdown('product_required', $options, 'aloeverajuice');
echo form_fieldset_close();
echo form_fieldset('How long has the particular problem gone on for? (multi-select)');
$preselected = array('sevendays', 'onemonth', 'sixmonths', 'twelvemonths');
$problem = array(
'sevendays' => 'Seven Days',
'onemonth' => 'One Month',
'sixmonths' => 'Six Months',
'twelvemonths' => 'Twelve Months',
);
echo form_dropdown('problem_duration[]', $problem, $preselected);
echo form_fieldset_close();
echo form_fieldset('Terms and Conditions');
echo form_label('Do you agree to our t&c? '. 'terms');
echo form_checkbox('terms', 'accept', TRUE);
echo form_submit('mysubmit', 'Submit');
echo form_close();
?>
</div>
</body>
</html>
下面是一些有助于理解控制器的更多内容。我似乎无法将任何内容发布到数据库中。在模型中,而不是
$sql = $this->db->insert_string('orders', $order);
$query = $this->db->query($sql);
使用
感谢您的帮助和快速响应。出于某种原因,它仍然没有将任何内容发布到phpmyadmin中
$sql = $this->db->insert_string('orders', $order);
$query = $this->db->query($sql);
$query = $this->db->insert('orders', $order);