1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wildcards in php help

Discussion in 'PHP & Perl' started by mightybh, Oct 4, 2009.

  1. mightybh

    mightybh Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 27, 2008
    Messages:
    1,029
    Likes Received:
    1,714
    Occupation:
    CEO
    Location:
    UK
    I am doing various manipulations depending on my referer. For example

    if($referer == "http://www.google.com")

    Is there a way to use a wildcard in case my referrer is not exact? Something like

    if($referer == "http://www.google.com*")

    to cover all the pages coming from google.

    Basically I need to have the whole domain rather than a specific page.


    Thank you!
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    PHP:
    if (ereg ("http://www.google.com*"$referer)) {
        echo 
    "ok";
    } else {
        echo 
    "Invalid referer";
    }
    regards
    Cyklotrial
     
    • Thanks Thanks x 1
  3. shade

    shade Junior Member

    Joined:
    Jan 1, 2009
    Messages:
    137
    Likes Received:
    179
    Occupation:
    Job? Whats a job?
    Location:
    America
    Home Page:
    or alternatively, to see if it contains the string in the referer

    PHP:
    if(stristr($referer"http://www.google.com")) {
             
    redirect_or_whatever();
    }
    else {
           
    same();
    }
     
    • Thanks Thanks x 1