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 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作