This paper presents a simple method for PHP to obtain and judge the source of the submission. Share to everyone for your reference, as follows:
echo $_server[' Http_referer '];
This gets the URL of the previous page
For example, get:
$url = http://www.weisuyun.com/nihao.html
Other pages submitted to not accept
The code is as follows:
if (Strpos ($url, ' http://www.weisuyun.com ')) {echo ' source is correct ';} Else{echo ' source unknown ';}
The Strpos method returns the position of the specified string where the specified string first appears, no returns false, and the subscript starts at 0
Add:
Stripos () -finds the position of the first occurrence of a string in another string (case insensitive)
Strripos () -finds the last occurrence of a string in another string (case insensitive)
Strrpos () -finds the last occurrence of a string in another string (case-sensitive)
Read more about PHP related content readers can view the topic: "Php+ajax Tips and Applications Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Primer Tutorial", "PHP operation Office Document Tips Summary ( including word,excel,access,ppt), PHP date and Time usage summary, PHP Primer for object-oriented programming, PHP string usage Summary, PHP+MYSQL database Operations Starter Tutorial, and A summary of common PHP database operation techniques
I hope this article is helpful to you in PHP programming.
The above describes the PHP simple access and determine the source of the method of submission, including PHP, the content of the method, I hope that the PHP tutorial interested in a friend helpful.