This article mainly introduces PHP's simple method of obtaining and determining the submission source, involving the use of $ _ SERVER and string operations in PHP, for more information about how to obtain and determine the submission source, see the example in this article. We will share this with you for your reference. The details are as follows:
Echo $ _ SERVER ['http _ referer'];
Obtain the url of the previous page.
For example:
$ Url = http://www.weisuyun.com/nihao.html
Other pages submitted are not accepted
The code is as follows:
If (strpos ($ url, 'http: // www.weisuyun.com ') {echo 'source right';} else {echo 'source unknown ';}
The strpos method returns the position where the specified string is located for the first time. if no value is found, false is returned. the subscript starts from 0.
Supplement:
Stripos ()-searches for the position of the string that appears for the first time in another string (case insensitive)
Strripos ()-locate the last occurrence of a string in another string (case insensitive)
Strrpos ()-locate the last occurrence of a string in another string (case sensitive)