Php Web表单正在向数据库提交空白数据
我正在尝试使用PHP将数据从web表单发送到数据库。用户在文本框中输入其Php Web表单正在向数据库提交空白数据,php,jquery,mysql,Php,Jquery,Mysql,我正在尝试使用PHP将数据从web表单发送到数据库。用户在文本框中输入其全名、联系电话和最佳通话时间详细信息。当框中填充了相关信息并点击submit时,数据会被添加到数据库中,只要列是空的。我如何解决这个问题 HTML <form name="frmContact" action="<?php $_PHP_SELF ?>" id="frmCallContact" method="POST"> enter code here<table width="100
全名
、联系电话
和最佳通话时间
详细信息。当框中填充了相关信息并点击submit时,数据会被添加到数据库中,只要列是空的。我如何解决这个问题
HTML
<form name="frmContact" action="<?php $_PHP_SELF ?>" id="frmCallContact" method="POST">
enter code here<table width="100%" border="0" cellspacing="1" cellpadding="0" class="TableFormat">
<tr>
<th align="left" valign="top" colspan="2">Call me back</td>
</tr>
<tr>
<td align="right" valign="top">Full Name:</td>
<td><input type="text" name="FullName" id="FullName_R" style="width:250px;" title="Please enter your full name"/></td>
</tr>
<tr>
<td align="right" valign="top">Contact Number:</td>
<td><input type="text" name="ContactNumber" id="ContactNumber_R" style="width:250px;" /></td>
</tr>
<tr>
<td align="right" valign="top">Best Time to Call:</td>
<td><input type="text" name="BestTime" id="BestTime_R" style="width:250px;" title="Please enter your best time to call"/></td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td><!--<a name="submit" href="#"><img src="/img/bn_submit.png" width="93" height="28" /></a>--><input type="submit" name="Submit" value="Submit">
</tr>
</table>
</form>
您的表单包含以下内容:'name=“FullName”'并且在PHP代码中使用:'full\u name'。使用print\u r($\u POST);看看你得到了什么。你所说的“数据添加到数据库中非常好,只是列是空的”是什么意思?如果数据添加得很完美,列就不应该是空的,对吗?@sandepnayak我的意思是连接很好,所以我可以将数据提交给我的database@Pakspul非常感谢。我没有意识到它们不匹配。与@Pakspul在其他字段中指出的错误相同。
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/bootstrap.php');
include("config/cn.php");
$template['template']="page";
if($_POST){
// Data pulled from input form
$full_name = $_POST['full_name'];
$contact_number = $_POST['contact_number'];
$best_time_to_call = $_POST['best_time_to_call'];
$enter_sql = "INSERT INTO contact (full_name,contact_number,best_time_to_call) VALUES('$full_name','$contact_number','$best_time_to_call')";
/*print($enter_sql);*/
$enter_query = mysql_query($enter_sql) or die(mysql_error());
header('Location: /thankyou.php');
exit;
}
?>
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/bootstrap.php');
include("config/cn.php");
$template['template']="page";
if($_POST){
// Data pulled from input form
$full_name = $_POST['FullName'];
$contact_number = $_POST['ContactNumber'];
$best_time_to_call = $_POST['BestTime'];
$enter_sql = "INSERT INTO contact (full_name,contact_number,best_time_to_call) VALUES('$full_name','$contact_number','$best_time_to_call')";
/*print($enter_sql);*/
$enter_query = mysql_query($enter_sql) or die(mysql_error());
header('Location: /thankyou.php');
exit;
}
?>