[英]safest way to process POST actions
這是我當前處理POST提交操作的方式:
<form action="process.php" method="post">
//several form fields
<input type="submit" name="ok" value="save" />
然后在處理頁面上我有這樣的東西:
if(isset($_POST['ok']) && $_POST['ok']=="save")
{
//process the action, and possibly save to database
}
現在我擔心惡意軟件可能會這樣做(通過他們網站上的腳本)
<form action="http://www.mysite.com/process.php" method="post">
//he can "view source" on my site, view the fields i'm having and put them
//then put the submit button
<input type="submit" name="ok" value="save" />
當然,有了這個,您會發現我會喝些熱湯。 那么我該怎么辦,或者處理和處理POST提交操作的最安全方法是什么?
您正在以錯誤的級別查看問題。 當然,您首先應該確保發出請求的任何人(您有會話,對嗎?)具有執行此請求所需的特權。 HTML表單中沒有任何內容可以阻止他們執行您描述的操作,因此您需要確保提交表單的人可以這樣做。
(從技術上講,您可以檢查Referrer,但這充其量是脆弱的)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.