如何使用get或post方法將用戶從視圖中輸入的數據傳遞給codeigniter Php中的控制器?我目前是新的codeigniter ..謝謝!使用Codeigniter從視圖獲取數據到控制器
AddProduct.php(我的視圖)
<body>
<form method="POST" action="SaveProductController"></br></br></br>
<table border='1' align='center'>
<tr>
<td>ID: </td><td><input type="text" name="id"
value="<?php echo $GetProductId->id + 1; ?>" readonly="readonly"></td>
</tr>
<tr>
<td>Description: </td><td><input type="text" name="description"></td>
</tr>
<tr>
<td></td><td><input type="submit" name="addProduct" value="Add Product"><td>
</tr>
</table>
</form>
</body>
SaveProductController .PHP(我的控制器)
class SaveProductController extends CI_Controller{
function index($description){
$this->load->model('ProductDao');
$data['id'] = $this->id;
$data['description'] = $this->description;
print_r($data);
//$this->ProductDao->saveProduct();
}
}
ProductDao.php
function saveProduct() {
$data = array(
'id' => $this->input->xss_clean($this->input->post('id')),
'description' => $this->input->xss_clean($this->input->post('description')),
'price' => $this->input->xss_clean($this->input->post('price')),
'size' => $this->input->xss_clean($this->input->post('size')),
'aisle' => $this->input->xss_clean($this->input->post('aisle')),
);
$query = $this->db->insert('mytable', $data);
}
什麼問題呢? – EbinPaulose
http://stackoverflow.com/questions/2279282/how-to-process-a-form-with-codeigniter –