-1
當用戶提交的數據,我將收到此錯誤插入數據使用自定義視圖在Opencart的
致命錯誤:未捕獲的錯誤:調用在C成員函數插入()在空:\ XAMPP \ htdocs中\ SMAC \目錄\控制器\金\ payment.php:45
這是我的TPL文件
<script type="text/javascript">
$('#submit').submit(function() {
$.ajax({ // create an AJAX call...
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(response) {
$('#submit').html(response);
}
});
return false;
});
</script>
<form action="<?php echo $action; ?>" method="post">
Your name: <input type="text" name="name" required><br>
Your e-mail: <input type="text" name="email" required><br>
<input type="submit" value="submit" name="submit">
</form
控制器的文件:
public function index()
{
$this->load->model('payment/payment');
$this->data['action'] = $this->url->link('payment/payment');
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
$id= $this->model_payment_payment->insert($this->request->post);
}
$this->response->setOutput($this->load->view('payment/payment', $data));
}
這是我的模型文件
<?php
class ModelPaymentPayment extends Model
{
public function insert($data)
{
$this->db->query("INSERT INTO " . DB_PREFIX . "naveen SET
name = '" . $this->db->escape($data['name']) . "',
email = '" . $this->db->escape($data['email']) . "'");
$address_id = $this->db->getLastId();
return $address_id;
}
}
如果我有什麼錯,請提起過。
你能告訴我你payment.php模型的路徑,因爲據我記得沒有目錄的/控制器/支付的文件夾。或者,也許你可以指定你使用哪個版本的opencart。 –