我是使用 PHP 的新手
这是我的 HTML
<html>
<head>
<link rel="stylesheet" type="text/css" href="design.css">
</head>
<form action="process.php" method="post">
<body>
Username: <input type="text" name="username" maxlength="45" ><br>
Password: <input type="text" name="password" maxlength="45"><br>
Confirm Password: <input type="text" name="password" maxlength="45"><br><br>
First Name: <input type="text" name="first_name" maxlength="45"><br>
Middle Name: <input type="text" name="middle_name" maxlength="45"><br>
Last Name: <input type="text" name="last_name" maxlength="45"><br>
Birthday: <input type="text" name="birthday" maxlength="45"><br>
E-Mail: <input type="text" name="email_add" maxlength="45"><br><br>
<input type="submit" value="SAVE" style="width: 120px;height: 25px;">
</body>
</form>
</html>
这是我的 PHP
<?php
$con=mysqli_connect("localhost","root","","sampledb");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO account (username, password, confirm_pwd, first_name,
middle_name, last_name, birthday, email_add) VALUES
('$_POST[username]','$_POST[password]','$_POST[confirm_pwd]',
'$_POST[first_name]','$_POST[middle_name]','$_POST[last_name]',
'$_POST[birthday]','$_POST[email_add]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
我哪里做错了?谁能告诉我?我做错什么了吗?当我尝试保存它时,它只是重定向到process.php
,我检查了数据库,但它没有向数据库插入任何数据。