我正在测试MySQL,我决定制作一个表单,在我的网站上提交反馈并存储它们。提交时,它会显示一个标记为“已提交”。问题是,它显示在网站的导航栏上方,所以很自然地,我希望它更加引人注目并且更接近主要内容。有没有办法使用PHP更改某个div的内容?
(另外,有没有办法让它每次刷新页面时都不提交表单?如果有任何重要性,请使用POST方法)
//Code Used:
//index.php: https://pastebin.com/SqyUFFqq
//dbc.php: https://pastebin.com/rHVufmmc
//(You guys seem to have something against pastebin, sorry if i broke the shadow protocol)
<!-- alright you win, here you go -->
<!-- heres the main thing that does the sql stuff
<?php
<!-- dbc.php is just setting vars to connect to the mysql db -->
require_once("../../../dbc.php");
if (isset($_POST['submit'])){
$name = $_POST['name'];
$feedback = $_POST['feedback'];
$query = "INSERT INTO feedback (id, name, feedback, date) VALUES (NULL, ?, ?, NOW())";
$stmt = mysqli_prepare($dbc, $query);
mysqli_stmt_bind_param($stmt, "ss", $name, $feedback);
mysqli_stmt_execute($stmt);
$affro = mysqli_stmt_affected_rows($stmt);
if ($affro == 1) {
echo "<h1>Submitted!</h1>";
mysqli_stmt_close($stmt);
mysqli_close($dbc);
} else {
echo "Error! Could not submit data. <br>";
echo mysqli_error($dbc);
mysqli_stmt_close($stmt);
mysqli_close($dbc);
}
}
?>
发布于 2018-09-30 14:26:39
那件事User3783243说:
用$ something替换echo =然后在你的代码中,你想要输出回显$ something;。
STILL ...如果有人知道如何制作它以便在我刷新页面时不会提交表单,请随时回答
https://stackoverflow.com/questions/-100002827
复制相似问题