{"id":28443,"date":"2024-11-24T09:29:01","date_gmt":"2024-11-24T01:29:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28443\/"},"modified":"2024-11-24T09:29:01","modified_gmt":"2024-11-24T01:29:01","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bd%bf%e7%94%a8-post-%e8%bf%9b%e8%a1%8c%e6%9b%b4%e6%96%b0%e6%af%94%e8%b6%85%e9%93%be%e6%8e%a5%e6%9b%b4%e5%ae%89%e5%85%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28443\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u4f7f\u7528 POST \u8fdb\u884c\u66f4\u65b0\u6bd4\u8d85\u94fe\u63a5\u66f4\u5b89\u5168"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173241072638578.jpg\" class=\"aligncenter\" title=\"\u4e3a\u4ec0\u4e48\u4f7f\u7528 POST \u8fdb\u884c\u66f4\u65b0\u6bd4\u8d85\u94fe\u63a5\u66f4\u5b89\u5168\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48\u4f7f\u7528 POST \u8fdb\u884c\u66f4\u65b0\u6bd4\u8d85\u94fe\u63a5\u66f4\u5b89\u5168\u63d2\u56fe\" \/><\/p>\n<p>\u5728 php \u4e2d\u66f4\u65b0\u8bb0\u5f55\u65f6\uff0c\u9009\u62e9\u4f7f\u7528 <strong>\u6267\u884c\u64cd\u4f5c<\/strong>\uff08\u901a\u5e38\u901a\u8fc7\u8868\u5355\u548c http \u65b9\u6cd5\uff0c\u5982 post \u6216 put\uff09\u8fd8\u662f <strong>\u8d85\u94fe\u63a5<\/strong>\uff08\u901a\u5e38\u4f7f\u7528 get \u65b9\u6cd5\uff09\u5f52\u7ed3\u4e3a<strong>\u5b89\u5168\u6027<\/strong>\u548c<strong>\u6700\u4f73\u5b9e\u8df5<\/strong>\u3002\u8fd9\u5c31\u662f<strong>\u6267\u884c\u64cd\u4f5c<\/strong>\u662f\u9996\u9009\uff1a<\/p>\n<hr>\n<h2> \u5b89\u5168 <\/h2>\n<ul>\n<li> <strong>get\uff08\u8d85\u94fe\u63a5\uff09\uff1a<\/strong> \u7531\u94fe\u63a5\u89e6\u53d1\u7684\u64cd\u4f5c\u901a\u5e38\u4f7f\u7528 get http \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u65e8\u5728\u68c0\u7d22\u4fe1\u606f\uff0c\u800c\u4e0d\u662f\u4fee\u6539\u4fe1\u606f\u3002\u5f53\u7528\u4e8e\u66f4\u65b0\u6216\u5220\u9664\u65f6\uff0c\uff08\u4f8b\u5982\u8bb0\u5f55 id\uff09\u53ef\u80fd\u4f1a\u5728 url \u4e2d\u66b4\u9732\uff0c\u4f7f\u5176\u5bb9\u6613\u53d7\u5230 <strong>url \u64cd\u7eb5\u6216 csrf<\/strong>\uff08\u8de8\u7ad9\u70b9\u8bf7\u6c42\u4f2a\u9020\uff09\u7b49\u653b\u51fb\u3002<\/li>\n<\/ul>\n<p>\u6709\u95ee\u9898\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;a href=\"update.php?id=123\"&gt;update&lt;\/a&gt;\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u64cd\u7eb5 url \u4e2d\u7684 id \u6765\u7be1\u6539\u672a\u7ecf\u6388\u6743\u7684\u8bb0\u5f55\u3002<\/p>\n<ul>\n<li> <strong>post\uff08\u6267\u884c\u64cd\u4f5c\uff09\uff1a<\/strong> \u66f4\u65b0\u5e94\u4f7f\u7528\u5e26\u6709 post \u65b9\u6cd5\u7684\u8868\u5355\uff0c\u5176\u4e2d\u6570\u636e\u5728\u8bf7\u6c42\u6b63\u6587\u800c\u4e0d\u662f url \u4e2d\u53d1\u9001\u3002\u8fd9\u79cd\u65b9\u6cd5\u9690\u85cf\u4e86\u654f\u611f\u4fe1\u606f\uff0c\u5e76\u4f7f\u672a\u7ecf\u6388\u6743\u7684\u64cd\u4f5c\u53d8\u5f97\u66f4\u52a0\u56f0\u96be\uff0c\u7279\u522b\u662f\u4e0e csrf \u4ee4\u724c\u7b49\u5176\u4ed6\u5b89\u5168\u63aa\u65bd\u7ed3\u5408\u4f7f\u7528\u65f6\u3002<\/li>\n<\/ul>\n<p>\u63a8\u8350\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;form action=\"update.php\" method=\"POST\"&gt;\n    &lt;input type=\"hidden\" name=\"id\" value=\"123\"&gt;\n    &lt;button type=\"submit\"&gt;Update&lt;\/button&gt;\n&lt;\/form&gt;\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<hr>\n<h2> \u9075\u5b88 http \u7ea6\u5b9a <\/h2>\n<p>http \u534f\u8bae\u5bf9\u6bcf\u4e2a\u65b9\u6cd5\u90fd\u6709\u660e\u786e\u7684\u610f\u56fe\uff1a<\/p>\n<ul>\n<li> <strong>get\uff1a<\/strong> \u68c0\u7d22\u4fe1\u606f\uff08\u5e42\u7b49\u4e14\u65e0\u526f\u4f5c\u7528\uff09\u3002<\/li>\n<li> <strong>post\/put\uff1a<\/strong>\u63d0\u4ea4\u6216\u66f4\u65b0\u4fe1\u606f\uff08\u975e\u5e42\u7b49\u4e14\u6709\u526f\u4f5c\u7528\uff09\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528 <strong>get<\/strong> \u8fdb\u884c\u66f4\u65b0\u6216\u5220\u9664\u7b49\u64cd\u4f5c\u8fdd\u53cd\u4e86\u8fd9\u4e9b\u7ea6\u5b9a\uff0c\u5e76\u4e14\u53ef\u80fd\u4f1a\u6df7\u6dc6\u7f13\u5b58\u6216\u4ee3\u7406\u7b49\u4e2d\u4ecb\u673a\u6784\uff0c\u8fd9\u4e9b\u4e2d\u4ecb\u673a\u6784\u53ef\u80fd\u4f1a\u5c06 <strong>get<\/strong> \u8bf7\u6c42\u89c6\u4e3a\u5b89\u5168\u4e14\u65e0\u526f\u4f5c\u7528\u3002<\/p>\n<hr>\n<h2> \u9632\u6b62\u610f\u5916\u884c\u4e3a <\/h2>\n<ul>\n<li>\u8d85\u94fe\u63a5\u53ef\u80fd\u4f1a\u65e0\u610f\u4e2d\u89e6\u53d1\uff08\u4f8b\u5982\uff0c\u610f\u5916\u70b9\u51fb\u6216\u673a\u5668\u4eba\u8ddf\u8e2a\u94fe\u63a5\uff09\u3002<\/li>\n<li>\u4f7f\u7528 <strong>post<\/strong> \u7684\u8868\u5355\uff0c\u5c24\u5176\u662f\u6dfb\u52a0\u4e86\u786e\u8ba4\u6b65\u9aa4\uff0c\u53ef\u4ee5\u964d\u4f4e\u610f\u5916\u6267\u884c\u7684\u53ef\u80fd\u6027\u3002<\/li>\n<\/ul>\n<hr>\n<h2> \u4e0e\u9ad8\u7ea7\u5b89\u5168\u6027\u548c\u9a8c\u8bc1\u7684\u517c\u5bb9\u6027 <\/h2>\n<p>\u4f7f\u7528\u8868\u5355\u53ef\u4ee5\u65e0\u7f1d\u96c6\u6210\u5176\u4ed6\u5b89\u5168\u63aa\u65bd\uff0c\u4f8b\u5982\uff1a<\/p>\n<ol>\n<li> <strong>csrf \u4ee4\u724c\uff1a<\/strong> \u9632\u6b62\u6076\u610f\u8de8\u57df\u8bf7\u6c42\u3002<\/li>\n<li> <strong>\u8f93\u5165\u9a8c\u8bc1\uff1a<\/strong>\u63d0\u4ea4\u8868\u5355\u4e4b\u524d\u9a8c\u8bc1\u8bb0\u5f55 id\u3002<\/li>\n<li> <strong>\u6743\u9650\u63a7\u5236\uff1a<\/strong>\u5728\u5448\u73b0\u8868\u5355\u4e4b\u524d\u9a8c\u8bc1\u7528\u6237\u8bbf\u95ee\u6743\u9650\u3002<\/li>\n<\/ol>\n<hr>\n<p>\u4f7f\u7528<strong>\u6267\u884c\u64cd\u4f5c<\/strong>\uff08\u901a\u8fc7\u5e26\u6709 post \u6216 put \u7684\u8868\u5355\uff09\u66f4\u65b0\u8bb0\u5f55\u662f\u63a8\u8350\u7684\u65b9\u6cd5\u3002\u8fd9\u53ef\u786e\u4fdd\u66f4\u597d\u7684\u5b89\u5168\u6027\u3001\u7b26\u5408 http \u7ea6\u5b9a\u5e76\u964d\u4f4e\u610f\u5916\u64cd\u4f5c\u7684\u98ce\u9669\u3002\u8d85\u94fe\u63a5\u5e94\u4fdd\u7559\u7528\u4e8e\u4e0d\u4f1a\u6539\u53d8\u7cfb\u7edf\u72b6\u6001\u7684\u5bfc\u822a\u6216\u53ea\u8bfb\u64cd\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 POST \u8fdb\u884c\u66f4\u65b0\u6bd4\u8d85\u94fe\u63a5\u66f4\u5b89\u5168\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 php \u4e2d\u66f4\u65b0\u8bb0\u5f55\u65f6\uff0c\u9009\u62e9\u4f7f\u7528 \u6267\u884c\u64cd\u4f5c\uff08\u901a\u5e38\u901a\u8fc7\u8868\u5355\u548c http \u65b9\u6cd5\uff0c\u5982 post \u6216 put\uff09\u8fd8\u662f \u8d85\u94fe\u63a5\uff08\u901a\u5e38\u4f7f\u7528 get \u65b9\u6cd5\uff09\u5f52\u7ed3\u4e3a\u5b89\u5168\u6027\u548c\u6700\u4f73\u5b9e\u8df5\u3002\u8fd9\u5c31\u662f\u6267\u884c\u64cd\u4f5c\u662f\u9996\u9009\uff1a \u5b89\u5168 get\uff08\u8d85\u94fe\u63a5\uff09\uff1a \u7531\u94fe\u63a5\u89e6\u53d1\u7684\u64cd\u4f5c\u901a\u5e38\u4f7f\u7528 get http \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u65e8\u5728\u68c0\u7d22\u4fe1\u606f\uff0c\u800c\u4e0d\u662f\u4fee\u6539\u4fe1\u606f\u3002\u5f53\u7528\u4e8e\u66f4\u65b0\u6216\u5220\u9664\u65f6\uff0c\uff08\u4f8b\u5982\u8bb0\u5f55 id\uff09\u53ef\u80fd\u4f1a\u5728 url \u4e2d\u66b4\u9732\uff0c\u4f7f\u5176\u5bb9\u6613\u53d7\u5230 url \u64cd\u7eb5\u6216 csrf\uff08\u8de8\u7ad9\u70b9\u8bf7\u6c42\u4f2a\u9020\uff09\u7b49\u653b\u51fb\u3002 \u6709\u95ee\u9898\u7684\u793a\u4f8b\uff1a &lt;a href=&#8221;update.php?id=123&#8243;&gt;update&lt;\/a&gt; \u767b\u5f55\u540e\u590d\u5236 \u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u64cd\u7eb5 url \u4e2d\u7684 id \u6765\u7be1\u6539\u672a\u7ecf\u6388\u6743\u7684\u8bb0\u5f55\u3002 post\uff08\u6267\u884c\u64cd\u4f5c\uff09\uff1a \u66f4\u65b0\u5e94\u4f7f\u7528\u5e26\u6709 post \u65b9\u6cd5\u7684\u8868\u5355\uff0c\u5176\u4e2d\u6570\u636e\u5728\u8bf7\u6c42\u6b63\u6587\u800c\u4e0d\u662f url \u4e2d\u53d1\u9001\u3002\u8fd9\u79cd\u65b9\u6cd5\u9690\u85cf\u4e86\u654f\u611f\u4fe1\u606f\uff0c\u5e76\u4f7f\u672a\u7ecf\u6388\u6743\u7684\u64cd\u4f5c\u53d8\u5f97\u66f4\u52a0\u56f0\u96be\uff0c\u7279\u522b\u662f\u4e0e csrf \u4ee4\u724c\u7b49\u5176\u4ed6\u5b89\u5168\u63aa\u65bd\u7ed3\u5408\u4f7f\u7528\u65f6\u3002 \u63a8\u8350\u793a\u4f8b\uff1a &lt;form action=&#8221;update.php&#8221; method=&#8221;POST&#8221;&gt; &lt;input type=&#8221;hidden&#8221; name=&#8221;id&#8221; value=&#8221;123&#8243;&gt; &lt;button type=&#8221;submit&#8221;&gt;Update&lt;\/button&gt; &lt;\/form&gt; \u767b\u5f55\u540e\u590d\u5236 \u9075\u5b88 http [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-28443","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28443"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28443\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}