代码如下: 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> </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/