i have this page inserting data from html form. no error is showing but no data is inserted either. here is my code given.
<?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());
}
?>
i don;t have any problem where the page redirected. Form validation is still remaining. in this table, only email,utid,username,password this four fields are NOT NULL. remaining are Null allowed.
As you can see, your missing field 11, see below :
Tips :
$_REQUEST['$Blabla']won’t work because using ‘ doesn’t work for parsing variable, use ” instead like that$_REQUEST["{$Blabla}"]. But, avoid that because PHP need to parse mean more power horse needed, use$_REQUEST[$Blabla]instead.While developing, I recommend the following lines at the top of your script :
It will display all errors. Even the one that aren’t really error. It will help you to write perfect code and standard code that’ll work everywhere.