douan7601 2014-05-04 17:31
浏览 41
已采纳

php / pdo INSERT函数不在phpmyadmin中显示字段内容

I'm trying to insert content from my form into my database. I'm using twitter bootstrap 3 to layout my website but here is the form;

<form class="form-horizontal" method="post" action="assets/mailreview.php" role="form">
<fieldset>

<!-- Form Name -->
<legend>Submit you're review</legend>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="firstname">First Name:</label>
  <div class="col-md-4">
  <input id="firstname" name="firstname" placeholder="" class="form-control input-md" type="text">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="surname">Last Name:</label>
  <div class="col-md-4">
  <input id="surname" name="surname" placeholder="" class="form-control input-md" type="text">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="email">Email:</label>
  <div class="col-md-4">
  <input id="email" name="email" placeholder="" class="form-control input-md" type="text">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="title">Job Title:</label>
  <div class="col-md-4">
  <input id="title" name="title" placeholder="New kitchen.." class="form-control input-md" type="text">

  </div>
</div>

<!-- Textarea -->
<div class="form-group">
  <label class="col-md-4 control-label" for="brief">Description:</label>
  <div class="col-md-4">
    <textarea class="form-control" id="brief" name="brief">please type you're review here</textarea>
  </div>
</div>

<!-- Button -->
<div class="form-group">
  <label class="col-md-4 control-label" for="submitbtn">Submit:</label>
  <div class="col-md-4">
    <button id="submitbtn" name="submitbtn" class="btn btn-primary">Submit</button>
  </div>
</div>

</fieldset>
</form>

As you can see I have set the submit action to respond to mailreview.php on doing so I receive no errors(after several and i mean several) however the form properties will not display in myphpadmin. It does insert a new row but not the field content.

here is mailreview.php

    <?php
    include_once("config.php");

$sql = "INSERT INTO review (firstname, lastname, email, title, brief) values(:firstname,:lastname,:email,:title,:brief)";

$stmt = $db->prepare($sql);

$stmt->bindParam(':firstname', $_POST['firstname'], PDO::PARAM_STR);
$stmt->bindParam(':lastname', $_POST['surname'], PDO::PARAM_STR);
$stmt->bindParam(':email', $_POST['email'], PDO::PARAM_STR);
$stmt->bindParam(':title', $_POST['title'], PDO::PARAM_STR);
$stmt->bindParam(':brief', $_POST['brief'], PDO::PARAM_STR);

$stmt->execute();

?>

any advice or support would be very grateful!!!

  • 写回答

2条回答 默认 最新

  • duan1933 2014-05-04 17:54
    关注

    You are missing colons on your list of values.

    Change this:

     $sql = "INSERT INTO review (firstname, lastname, email, title, brief) values(firstname,lastname,email,title,brief)";
    

    to:

     $sql = "INSERT INTO review (firstname, lastname, email, title, brief) values(:firstname,:lastname,:email,:title,:brief)";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀