我有这个页面从 html 表单插入数据。没有显示错误,但也没有插入数据。这是我给出的代码。
<?php
mysql_connect("localhost","root","");
mysql_select_db("hcp");
$queryUserType = "select * from user_type";
$resultUserType = mysql_query($queryUserType) or die(mysql_error());
$queryTitle = "select * from name_titles";
$resultTitle = mysql_query($queryTitle) or die(mysql_error());
$time = time();
$date = date("d-m-y");
$nowDateTime=$time.$date;
if($_REQUEST['btnUserSubmit'])
{
$queryInsertUser="INSERT INTO users (`title_id`, `first_name`, `last_name`, `email`, `utid`, `residence_address1`, `residence_address2`, `residence_city`, `residence_state`, `residence_country`, `residence_zipcode`, `phone_no`, `username`, `password`, `created`, `date_of_birth`, `gender` ) VALUES ('".mysql_real_escape_string($_REQUEST['$rowTitle[0]'])."', '".mysql_real_escape_string($_REQUEST['txtFirstName'])."', '".mysql_real_escape_string($_REQUEST['txtLastName'])."', '".mysql_real_escape_string($_REQUEST['txtEmail'])."', '".mysql_real_escape_string($_REQUEST['rowUserType[0]'])."', '".mysql_real_escape_string($_REQUEST['txtAddressLine1'])."', '".mysql_real_escape_string($_REQUEST['txtAddressLine2'])."', '".mysql_real_escape_string($_REQUEST['txtCity'])."', '" .mysql_real_escape_string($_REQUEST['txtState'])."', '".mysql_real_escape_string($_REQUEST['txtCountry'])."', '".mysql_real_escape_string($_REQUEST['txtPhone'])."', '".mysql_real_escape_string($_REQUEST['txtUserName'])."', '".mysql_real_escape_string($_REQUEST['txtUserPassword'])."', '".$nowDateTime."', '".mysql_real_escape_string($_REQUEST['txtdateofbirth'])."', '".mysql_real_escape_string($_REQUEST['rdGender'])."');";
$resultinsert=mysql_query($queryInsertUser) or die(mysql_error());
}
?>
我在页面重定向的地方没有任何问题。表单验证仍然存在。在这个表中,只有 email、utid、username、password 这四个字段不为空。其余为 Null 允许。