注意:第16行F:\wamp64\www\practice\insert.php中的未定义索引:username
我是在youtube的一个频道上做的。。我只是复制了所有的代码,但仍然不起作用。你能在这件事上帮我吗。我在结尾处遇到错误,说“未插入”注意:第16行F:\wamp64\www\practice\insert.php中的未定义索引:username,php,indexing,undefined,Php,Indexing,Undefined,我是在youtube的一个频道上做的。。我只是复制了所有的代码,但仍然不起作用。你能在这件事上帮我吗。我在结尾处遇到错误,说“未插入” **index.php** <html> <head> <title>Data entry practise</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <bo
**index.php**
<html>
<head>
<title>Data entry practise</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="wrapper">
<form action="insert.php" method="_POST">
Name: <input type="text" name="username"><br><br>
Email Address: <input type="text" name="email"><br><br>
<input type="submit" value="insert">
</form>
</div>
</body>
</html>
**index.php**
数据输入练习
名称:
电子邮件地址:
现在是inset.php代码部分。似乎这里有一些错误。。请帮帮我
**insert.php**
<?php
$con = mysqli_connect('localhost','root','');
if(!$con)
{
echo "not connected";
}
if(!mysqli_select_db($con,'tutorial'))
{
echo 'database Note Selected';
}
$Name = $_POST['username'];
$Email = $_POST['email'];
$sql = "INSERT INTO person (Name,Email) VALUES ('$Name', '$Email')";
if(!mysqli_query($con, $sql))
{
echo "Not Inserted";
}
else
{
echo "Inserted";
}
?>
**insert.php**
问题是表单方法不正确。你必须不带下划线地写
**index.php**
<html>
<head>
<title>Data entry practise</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="wrapper">
<form action="insert.php" method="POST">
Name: <input type="text" name="username"><br><br>
Email Address: <input type="text" name="email"><br><br>
<input type="submit" value="insert">
</form>
</div>
</body>
</html>
我用你的代码进行了测试,它正在工作
还有一件事,您需要将表单方法更改为“POST”,不带下划线,这一点很重要。如果我想查看其他帖子,而不是不在此处发布,请从代码上下文中回答我的可能重复内容。。所以,请帮我看一下代码并解决它。这里有禁止复制帖子的规则。你的帖子应该关闭了。如果你不知道如何通过阅读类似的文章来解决你的问题,那么也许你不应该做软件工程。它仍然不起作用。我已经做了所有的工作,没有下划线,有下划线。。但仍然没有插入数据
$con = mysqli_connect('localhost','root','', 'tutorial');
if(!$con)
{
echo "not connected";
}
if(!mysqli_select_db($con,'tutorial'))
{
echo 'database Note Selected';
}
$Name = $_POST['username'];
$Email = $_POST['email'];
$sql = "INSERT INTO person (Name,Email) VALUES ('$Name', '$Email')";
if(!mysqli_query($con, $sql))
{
echo "Not Inserted";
}
else
{
echo "Inserted";
}
?>