- 保存在 htdocs 目录中的文件** 当我运行该文件时,我在 url 中将其更改为:localhost/aa.html
html 文件 (aa.html):
<!DOCTYPE html>
<html>
<head>
<title>RegPage</title>
</head>
<body>
<form action ="bb.php" method="post">
name: <input type="text" name "username">
<br/>
email: <input type="text" name ="email">
<br/>
password: <input type="password" name="password">
<input type = "submit" value = "insert">
</form>
</body>
</html>
php 文件 (bb.php):
<?php
$con=mysqli_connect('localhost','root','');
if(!con)
{
echo 'not connected to server';
}
if (!mysqli_select_db ($con,'pilot'))
{
echo 'database not selected';
}
$name=$_post['username'];
$email=$_post['email'];
$password=$_post['password'];
$sql="insert into dbinvestor (email,password,name) values ('$email','$password', '$name')";
if (!mysqli_query($con,$sql))
{
echo 'not inserted';
}
else
{
echo 'inserted succesfuly';
}
header ("refresh:2;url=aa.html");
?>
数据库和表: 数据库
输出: 输出
不知道怎么解决,谢谢帮助!