【发布时间】:2020-05-22 00:18:36
【问题描述】:
我正在尝试测试一个非常简单的 PHP 表单,它将输入插入 SQL 数据库。连接工作正常,但是当我刷新它时数据没有出现在数据库中。我只有两个文件,一个 index.html 和一个 process.php。
index.html:
<html>
<head>Testing</head>
<body>
<div id="frm">
<form action="process.php" method=POST>
<p>
<label>Username</label>
<input type="text" id="stuff" name="stuff">
</p>
<p>
<input type="submit" id="btn" value="Login">
</p>
</form>
</div>
</body>
</html>
进程.php:
<?php
$userinput = $_POST['stuff'];
$servername = "localhost";
$username = "root";
$password = "";
$database = "testing";
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error)
{
die("connection failed: " . $conn->connect_error);
}
else
{
echo "Connected successfully ";
echo $userinput;
$sql = "INSERT INTO `entries`(`input`) VALUES ('$userinput')";
}
?>
【问题讨论】:
-
如果提交查询,脚本的哪一部分?没有