【发布时间】:2019-05-15 15:24:25
【问题描述】:
- 保存在 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");
?>
数据库和表: DB
输出: OutPut
不知道怎么解决,谢谢帮助!
【问题讨论】:
-
=在您的表单name "username"上丢失。$_POST也必须大写。 -
@TarangP 电子邮件和密码 - varchar,名称 - 文本
-
未定义索引
username那是你的错误 -
@Roms 工作,非常感谢:)
-
@FireFun365 解决了部分问题,请参阅下面的答案
标签: php mysql sql database xampp