This article describes a simple way to obtain and judge the source of a submission in PHP. Share to everyone for your reference, specific as follows:
echo $_server[' Http_referer '];
This gets the URL of the previous page
For example, you get the following:
$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 is correct ';
} else{
Echo ' source unknown ';
}
The Strpos method returns the first occurrence of the specified string where the specified string is located, without returning false, and the subscript starts at 0
Add:
Stripos () -Find the position where the string first appears in another string (case-insensitive)
Strripos () -Find out where the string last appears in another string (case-insensitive)
Strrpos () -finds the last occurrence of a string in another string (case-sensitive)
For more information about PHP interested readers can view the site topics: "Php+ajax Tips and Applications Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP basic Grammar Introductory Course", "PHP operation Office Document Skills Summary ( including word,excel,access,ppt), the "Summary of PHP date and time usage", "PHP Introduction to Object-oriented Programming", "PHP string (String) Usage Summary", "Php+mysql database Operation Tutorial" and " A summary of common PHP database operations tips
I hope this article will help you with the PHP program design.