Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2005
    Location
    Pakistan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Domain Name/URL extract

    Hello Dear Friends,

    I'm facing a problem with PHP programming to complete my email application.

    I want visitors to be restricted to use my email form via various locations.

    i.e, I want to ALLOW some predefined URL (saved in database)

    * www.abc.com
    * www.xyz.com

    $refer = $_SERVER['SERVER_NAME'];

    it doesn't solve the problem.

    can anybody please let me know the exact code or snippet to be used for such purpose?

    Thanks & Best Regards
    Muhammad Zeeshan Arshad
    Offshore Web Professional
    1. Official Website
    2. Center of Islam Science

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Try something like this...

    PHP Code:
    $validURIs = array("www.xyz.com","www.abc.com"); //you could populate this with a database query

    if(in_array($_SERVER['HTTP_REFERER'],$validURIs)) {
        
    //it's valid
    }
    else {
        
    //it's invalid

    I may have the arguments backward in the in_array() function (I can never remember that stuff - www.php.net is your friend).

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are like me, I could never remember until I forced myself... Yes though, you do have them the right way round ... i can recite that page of the php.net manual now lol :P...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •