Php prevents counterfeit data from being submitted from the URL. Php prevents counterfeit data from being submitted from the URL. The following code first checks the source of the previous page for the submission of forged data from a URL :? * PHP prevents the non-site data submitted by php from using the URL-based submission method for forged data.
The following code first checks the source of the previous page for the submission of forged data from a URL:
This method can only prevent the URL entered manually on the browser bar.
In fact, as long as a hyperlink (www.jbxue.com) is constructed on the server to point to the URL, such as adding a hyperlink to the post and then clicking it, this Check will not work at all.
Currently, it is relatively reliable to transmit important data using the POST method.
You can insert some hidden text into the form to transfer data.
Alternatively, use Ajax to submit data to the server from the client.
/* Create an XHR object */function createXHR () {if (window. XMLHttpRequest) {var oHttp = new XMLHttpRequest (); return oHttp;} // www. jbxue. comelse if (window. activeXObject) {var versions = ["MSXML2.XmlHttp. 6.0 "," MSXML2.XmlHttp. 3.0 "]; for (var I = 0; I <versions. length; I ++) {try {var oHttp = new ActiveXObject (versions [I]); return oHttp;} catch (error) {}}} throw new Error ("Your browser does not support AJAX! ");}/* Use AJAX to pass data to the page */function ajaxPost (url, query_string ='') {var xhr; xhr = createXHR (); xhr. open ('post', url, false); xhr. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset = gb2312"); xhr. onreadystatechange = function () {if (xhr. readyState = 4) if (xhr. status! = 200) return;} xhr. send (query_string );}
Bytes. The following code first checks the source of the previous page for the submission of forged data from a URL :? /* PHP prevents the party that submits data outside the site...