我刚刚创建了一个PHP代码来添加名称,电子邮件等添加到表格中,当我点击刷新时,会出现相同的信息行,如果用户刷新,我不希望这样做页...
好的,我有这个page1.php你可以输入信息,它会将你重定向到page2.php但是当我点击F5时它再次输入相同的信息
(我只是白痴 - 如果有人想刷新页面或意外刷新它,对吧?)
page1.php中:
<html>
<body>
<form action="page2.php" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
Email: <input type="text" name="email" />
<input type="submit" />
</form>
</body>
</html>
使page2.php:
$sqlinsert="INSERT INTO sampletable (FirstName, LastName, Email)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[email]')";
if ($conn-> multi_query($sqlinsert) === TRUE) {
echo "New record created successfully.<br>";
} else {
echo "Error: " . $sqlinsert . "<br>" . $conn->error;
}
$conn->close();