php - 没有任何内容会插入到我的数据库中

标签 php mysql html

代码如下: contact_us2.php

   <form id="form1" method="post" action="enquires.php">
 <fieldset>
 <legend>Form to database example</legend>
  <label for="text">
      <span>Comments:</span>
    <textarea id="text" name="comments" rows="4" cols="80"></textarea>
      </label>
      <label for="name">
     <span>Name:</span>
      <input id="name" type='text' name='name' size='50'/>
       </label>
      <label for="email">
    <span>Email:</span>
  <input id="email" type='text' name='email' size='50'/>
      </label>

     <label for="submit1" id="submit"><span>&nbsp;</span>
      <input id="submit1" class="submit" type="submit" name="submit" value="Submit"/>
      </label>
     </fieldset>
    </form>


                 enquires.php

                <?php
        session_start();
        error_reporting(E_ALL & ~E_NOTICE);
        require('authenticate.php');
        include_once"../scripts/connect_to_mysql.php";
        $name  = $_post['name'];
        $email = $_post['email'];
        $comments = $_post['comments'];
        echo "$email";
        // Query the body section for the proper page
        mysql_select_db("hardware_cms" )or die (mysql_error());
        $sqlCommand = MYSQL_QUERY("INSERT INTO enquires (id, name, email,      comments)". "VALUES ('NULL', '$name', '$email', '$comments')") or die (mysql_error()); 
        ?>

没有错误。插入数据库的唯一内容是 id。我认为问题出在 contact_us2.php 中。我是 html 和 php 的新手,如果这是一个愚蠢的问题,我很抱歉。

最佳答案

错误出现在 php 代码中,因为您必须使用 $_POST 而不是 $_post

 $name  = $_POST['name'];
 $email = $_POST['email'];
 $comments = $_POST['comments'];

关于php - 没有任何内容会插入到我的数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12479224/

相关文章:

php - 批号压​​痕器和美化器

javascript - 我如何为由于调用了 $.fadeIn() 的其他附近元素而移动的元素设置动画?

php - 如何使用搜索和替换通过 API 修改 Google Docs 文档?

php - iOS:如何使用给定 token 的 AFOAuth1Client

php - $_FILES 超全局变量可以在类中访问吗

mysql - 如何检查 MySQL 中列的索引

mysql - 这些以前应该用 MySQL 编写的 SQL 语句现在是 MySQLi 的提示吗?

如果未进行连接,则 Mysql 选择列为 null

jquery - 垂直对齐div中的内容

javascript - 如何让我的 javascript 组合三种颜色?