0
我需要'確認表單重新提交'信息(查看查看源代碼時進入Chrome)的幫助重定向與發佈數據是可能的?
如果我刪除評論,它只顯示用戶名1,無論我選擇哪個ID,並且評論如下代碼,與重新提交信息的作品...
<?php
$username = get_username_from_db(1);
if (isset($_POST['id'])) {
$id = $_POST['id'];
$username = get_username_from_db($id);
/*
// if this comment stay as comment, username will update with 'confirm form resubmission' message
// else 'confirm form resubmission' message not shows but username not updated (keep as default [1])
header('Location: ' . $_SERVER['HTTP_HOST']);
exit();
*/
}
?>
<body>
<form method="POST">
<fieldset>
<legend>Choose ID</legend>
<select name="id" onchange="this.form.submit()">
<option value="1">1st</option>
<option value="2">2nd</option>
<option value="3">3rd</option>
</select>
<br>
<label>Username:</label>
<input type="text" name="username" value="<?php echo $username; ?>">
</fieldset>
</form>
</body>
有什麼想法嗎?
還有沒有使用GET的選項? –
是的,你可以用php session()來做到這一點()只有你會更多的代碼待辦事項 – Paules
用會話代碼編輯我的答案 – Paules