PHP simple method for obtaining and determining the submission source

Source: Internet
Author: User
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)

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.