问题是只存储了密码,但其余的没有...... 这是php代码
<?php
define('DB_NAME','my_db');
define('DB_USER','root');
define('DB_PASSWORD','123');
define('DB_HOST','localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
$firstname = isset($_POST['fname']) ? $_POST['fname'] : '';
$lastname =isset($_POST['lname']) ? $_POST['lname'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$bday = isset($_POST['bday']) ? $_POST['bday'] : '';
$gender = isset($_POST['gender']) ? $_POST['gender'] : '';
$pass = isset($_POST['password']) ? $_POST['password'] : '';
$submit = isset($_POST['submit']) ? $_POST['submit'] : null;
$sql = "INSERT INTO user(fname,lname,email,bday,gender,password)
VALUES ('$firstname','$lastname','$email','$bday','$gender','$pass')";
if(!mysql_query($sql)){
die('Error: ' . mysql_error());
}
mysql_close();
?>
这是html代码
<form action="connect.php" method="post">
First name: <input type="password" name="fname">
Last name: <input type="text" name="lname"><br><br>
Email Address: <input type="email" name="email"><br><br>
Birthday: <input type="date" name="bday">
Sex: <input list="Sex" name="gender">
Password: <input type="password" name="password"><br><br>
<datalist id="Sex">
<option value="Male">
<option value="Female">
</datalist><br><br>
<input type="submit" value="Sign up!" id="btnsignup" />
</form>
*表中数据类型为:fname为varchar,lname为varchar,email为varchar,bday为date,gender为char,password为char *