For spoofed data submitted from a URL, the following code is first checked from the previous page source:
<?/*php method to prevent data submission outside the station * *
function Checkurl () {
$servername =$_server[' server_name '];
$sub _from=$_server["Http_referer"];
$sub _len=strlen ($servername);
$checkfrom =substr ($sub _from,7, $sub _len);
if ($checkfrom!= $servername) die ("Warning!)" You are submitting data from the outside! Please terminate immediately! ");
}
? >
This method only prevents URLs that are manually entered on the browser's address bar.
In fact, as long as a hyperlink to the URL is constructed on the server (www.jb51.net), such as adding a hyperlink to a post, and then clicking, the check doesn't work at all.
At present, it is more reliable to transmit important data by post method.
You can insert some hidden text in the form to pass data.
Or use Ajax to submit data from the client to the server using the following method.
* * Create XHR object/function Createxhr () {if window.
XMLHttpRequest) {var ohttp = new XMLHttpRequest (); return ohttp;} else 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 transfer data to page pages */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!=) return; Xhr.send (query_string); }