【发布时间】:2011-12-05 20:51:28
【问题描述】:
我正在尝试使用此代码将用户插入的记录插入到数据库中,但是当我转到数据库时,我没有找到任何记录将其插入我的数据库中,所以出了什么问题??? 顺便说一句,我使用 xampp 程序制作了我的数据库
<?php
if (isset($_POST['Postback']))
{
mysql_connect ("localhost") or die ('Error: ' .mysql_error());
mysql_select_db ("car_rental_db");
$Gender ='Female';
if ($_POST['RadioGender'] == 'Radio')
{
$Gender ='Male';
}
if($_POST['PasswordField']!= $_POST['ConfirmPassword'])
{
echo "This password doesn't match the confirmation password.<br>";
}
else if (strlen($_POST['PasswordField']) < 6 && strlen($_POST['PasswordField']) > 1)
{
echo "Your password must be longer than 6 characters.<br>";
}
else if ($_POST['PasswordField']== '')
{
echo "Please type a password, and then retype it to confirm.<br>";
}
else
{
}
$query = "INSERT INTO register_user (`FirstName`,`LastName`,`Email`,`Gender`,`Password`,`Birthday`,`Country`,`State`) VALUES('null'". $_POST['FirstName'] ."','". $_POST['LastName'] ."','" . $_POST['EmailField']."','".$Gender."','". $_POST['PasswordField'] ."','". $_POST['BirthdayTextFiled'] ."','". $_POST['SelectCountry'] ."','". $_POST['SelectState'] ."')";
echo $query;
//die ;
//header('Location: http://localhost/website/index.php');
}
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="RegistrationForm">
【问题讨论】: