填充数据库中的表

时间:2014-04-16 14:04:38

标签: php database

这是我的代码。

if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

if(! get_magic_quotes_gpc() )
{
   $User_F_Name = addslashes ($_POST['User_F_Name']);
   $User_L_Name = addslashes ($_POST['User_L_Name']);
}
else
{
   $User_F_Name = $_POST["User_F_Name"]; 
   $User_L_Name = $_POST["User_L_Name"];
}
$User_Name = $_POST["User_Name"];
$User_Email = $_POST["User_Email"];
$User_Password = $_POST["User_Password"];
$User_Interest_Reasons = $_Post["User_Interest_Reasons"];

$to      = $User_Email;
$subject = "Welcome to $website $User_F_Name";
$message = "Welcome $User_F_Name $User_L_Name,\n Login:$User_Name\n Password:$User_Password\n Please wait for your account to be reviewed and activated";
$headers = "From: webmaster@$website' . "\r\n" .
   'Reply-To: webmaster@$website' . "\r\n" .
   'X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);

$sql = "INSERT INTO users".
       "(User_F_Name,User_L_Name, User_Name, User_Email, User_Password, User_Interest_Reasons, User_Covenant_Agreement) ".
       "VALUES('$User_F_Name','$User_L_Name','$User_Name','$User_Email','$User_Password','$User_Interest_Reasons',1)";



mysql_select_db('prayer');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";


mysql_close($conn);
}
else
{
?>
<form method="post" action="AccountCreation1.php" style="width: 500px"><input type='hidden' name='__token_timestamp__' value='1397602997'><input type='hidden' name='__token_val__' value='5c5ba33158f2d12ecbb113a5da921ee0'>
<fieldset>
<input type='hidden' name='__token_timestamp__' value='1397526990'>
<input type='hidden' name='__token_val__' value='34a10d1cfc4b20e45c901e83624677ad'>
<p style="text-align: center">New User Account</p>
<div style="width: 500px; float: left">
<br />First Name: <input name="User_F_Name" type="text" id="User_F_Name">
<br />Last Name: <input name="User_L_Name" type="text" id="User_L_Name">
<br />User Name: <input name="User_Name" type="text" id="User_Name">
<br />Password: <input name="User_Password" type="text" id="User_Password">
<br />Email Address: <input name="User_Email" type="text" id="User_Email">
<br />Interest Reasons: 
<br /><textarea name="User_Interest_Reasons" type="varchar" id="User_Interest_Reasons" rows="5" cols="30"></textarea>
<br /><br />
</div>
<input name="add" type="submit" id="add" value="Add User Account">
</fieldset>
</form>
<?php
}
?>

一切正常,但&#34; User_Interest_Reasons&#34;不会在数据库中填充。所有其他值在数据库中填充得很好。我已确定位置名称是正确的。

2 个答案:

答案 0 :(得分:1)

PHP在某种程度上区分大小写...因此$_Post无效,$_POST会:)

答案 1 :(得分:0)

对于变量名称,PHP区分大小写。目前,获取user_interest_reasons的代码是:

$User_Interest_Reasons = $_Post["User_Interest_Reasons"];

虽然它应该是:

$User_Interest_Reasons = $_POST["User_Interest_Reasons"];