php - 表单未将数据发送到数据库?

标签 php mysql database forms

我创建了一个表单,我正在尝试将从表单收集的数据提交到我在 mysql 中创建的表中。以下是我尝试用来提交此数据的代码,但它不起作用,我的表仍然是空的?

public function action_claimincentive() {
    $this->template->content = View::factory('crm/uk/claim_incentive_form');
    $this->template->content->thanks = false;
    $this->template->content->val = '';
    $this->template->content->post = '';

    if ($this->request->post('form')) {
        $post = $this->request->post('form');

        $stmt = DB::query(Database::INSERT, 'INSERT INTO `claim_incentive_form_data` (`form_id`,`Claimant Name`, `Claimant Postcode`, `Purchase Order No.`, `Claimant Email Address`, `Storename`, `Storetown`, `Date of Sale`, `Date of Delivery`, `Tempur Acknowledgement No.`, `Tempur Product`)
        VALUES (:claimantname, :claimantpostcode, :orderno, :email, :storename, :storetown, :dateofsale, :dateofdelivery, :acknowledgementno, :tempurproduct)');
        $stmt->param(':claimantname', $post['claimantname']);
        $stmt->param(':claimantpostcode', $post['claimantpostcode']);
        $stmt->param(':orderno', $post['orderno']);
        $stmt->param(':email', $post['email']);
        $stmt->param(':storename', $post['storename']);
        $stmt->param(':storetown', $post['storetown']);
        $stmt->param(':dateofsale', $post['dateofsale']);
        $stmt->param(':dateofdelivery', $post['dateofdelivery']);
        $stmt->param(':acknowledgementno', $post['acknowledgementno']);
        $stmt->param(':tempurproduct', $post['tempurproduct']);
        try {
            $stmt->execute();
            $this->template->content->post = $post;
            $this->template->content->thanks = true;
        } catch (Exception $e) {
            FB::error($e);
        }

    }
}

最佳答案

已插入 11 列,但仅插入 10 个值。 我认为您不小心包含了 form_id

关于php - 表单未将数据发送到数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20633489/

相关文章:

database - MySQL 的替代品

php - 使用 PHP 和 cURL 复制 HTTP 请求

php - PDO 中的预处理语句真的能提高安全性吗?

mysql:从表中选择 * 但在特定列中具有唯一值

mysql - 在性能开始下降之前 MySQL 数据库可以有多大

Mysql - 使用 limit IN 并检查是否收到 N 行

php - Laravel 5.5 $exception instanceof AuthenticationException 未按预期工作

php - JS中的动态选择选项

html - 获取网站名称包含python 27中的HTML代码

php - 如何在 SQL (MySQL) 中合并两个表?