gpt4 book ai didi

php - Web 表单正在向数据库提交空白数据

转载 作者:行者123 更新时间:2023-11-29 13:11:03 26 4
gpt4 key购买 nike

我正在尝试使用 PHP 将数据从 Web 表单发送到我的数据库。用户在文本框中输入他们的full_namecontact_numberbest_time_to_call 详细信息。当方框填满相关信息并点击提交时,数据会完美地添加到数据库中,只是列是空白的。我该如何解决这个问题?

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">&nbsp;</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>

PHP

    <?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;
}

?>

关于php - Web 表单正在向数据库提交空白数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22093524/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com