填写表单后单击保存按钮时,应将其保存在数据库中,并应重定向到编辑页面,我可以在其中编辑字段。
答案 0 :(得分:0)
诀窍是POST
表单到当前页面,使用您喜欢的方法将数据保存到数据库中,然后重定向到下一页。
看看下面的例子:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Insert into database
$stmt = "INSERT INTO table (something) VALUES ('".$_POST['data']."')";
// Redirect
header("Location: nextpage.php");
exit;
}
?>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="POST" role="form">
<div>
<label for="data">Your data to insert into the database</label>
<input type="text" name="data" id="data" placeholder="Data to insert">
</div>
<button type="submit">Save</button>
</form>