The example in this article describes how to simply obtain and determine the source of submission in PHP. Share it with everyone for your reference, the details are as follows:
echo $_SERVER['HTTP_REFERER'];
This gets the url of the previous page
For example, what you get is:
$url = http://www.weisuyun.com/nihao.html
Submissions from other pages will not be accepted
The code is as follows:
if(strpos($url,'http://www.weisuyun.com')){ echo '来源正确'; }else{ echo '来源不明'; }
The strpos method returns the position where the specified string appears for the first time, otherwise it returns false, and the subscript starts from 0
Supplement:
stripos() - Finds the first occurrence of a string within another string (case insensitive)
strripos() - Finds the last occurrence of a string within another string (case insensitive)
strrpos() - Finds the last occurrence of a string within another string (case sensitive)
Readers who are interested in more PHP-related content can check out the special topics on this site: "Summary of PHP ajax skills and applications", "Summary of PHP operations and operator usage", "Summary of PHP network programming skills", "PHP basic syntax" "Introductory Tutorial", "Summary of PHP Office Document Skills (Including Word, Excel, Access, PPT)", "Summary of PHP Date and Time Usage", "Introduction to PHP Object-Oriented Programming", "php String Usage" Summary", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone in PHP programming.