[英]404 error when submitting form
嘗試提交此表單時,我不斷收到 404 錯誤。 在我的網站目錄中,我有一個名為mobile
的文件夾,其中有forms.php
和process.php
。
表格位於此頁面
http://localhost/mobile/forms.php?ft=0&id=2
這是表格
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
//details
</form>
當我嘗試提交時,我得到一個 404 錯誤,什么時候應該 go 到http://localhost/mobile/process.php?o=9&ft=0
我該如何解決?
通過查看URL,我得出的結論是兩個php文件都在同一頁面上,因此請從
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
至
<form action='process.php?o=9&ft=0' method='POST'>
mobile
之前的斜杠表示它從根目錄中選擇了文件夾。因此,您在此處可能不需要。
最后但並非最不重要的一點,請確保文件名正確,並確保大小寫相同,因為文件名區分大小寫。
注意:如果使用
header('Location: xyz.php');
也可能會收到404錯誤header('Location: xyz.php');
在表單處理頁面上,用於在表單處理后將用戶重定向到某個頁面,您可能會遇到404
因為不存在腳本已重定向到的頁面。 因此,如果您使用header()
確保網址正確
嘗試改變
<form action='/mobile/process.php?o=9&ft=0' method='POST'>
至
<form action='process.php?o=9&ft=0' method='POST'>
由於它們位於同一目錄中。
您不能在表單操作中傳遞GET參數。
為了傳遞參數,您將必須創建一個隱藏的輸入,如:
<input type="hidden" name="o">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.