-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。 –