A simple way to get and judge the source of a submission _php tips

Source: Internet
Author: User
Tags php database php introduction

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.