Banning email domains

Discussion in 'PHP' started by amelen, Nov 15, 2007.

  1. #1
    I have a form that is receiving a user sign up (name, email, etc..). I get the value in the php file with $HTTP_POST_VARS
     
    amelen, Nov 15, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    // Email from user
    $email = 'example@put2.net';
    
    $banned_providers = array('put2.net', 'temporaryinbox.com');
    
    if (in_array(strtolower(end(explode('@', $email))), $banned_providers))
    {
    	// throw error
    }
    
    PHP:
     
    nico_swd, Nov 15, 2007 IP
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    $temp = explode('@', $HTTP_POST_VARS[email]);
    if($temp[1] == 'put2.net') { not allowed code}
    else { welcome code }
    PHP:
     
    greatlogix, Nov 15, 2007 IP
  4. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #4
    So if I wanted it to check against the email submitted in the form, I would put this at the top: $email = $HTTP_POST_VARS ?
     
    amelen, Nov 15, 2007 IP
  5. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #5
    Hey nico_swd I like your code. Excellent Job.
     
    greatlogix, Nov 15, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
     
    nico_swd, Nov 15, 2007 IP
  7. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #7
    Thanks! This one guy has been spamming our sign ups with thousands of accounts per day. Our security prevents him from actually validating the accounts, so all it does is fill up our DB with crap. I tried some captcha but it didn't help for some reason, so hopefully this puts an end to it.

    Thanks!
     
    amelen, Nov 15, 2007 IP
  8. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #8
    Okay, I have the code, but it doesn't seem to be stopping this guy from signing up with the banned provider. This is at the top of my php file:

    Any ideas?
     
    amelen, Nov 15, 2007 IP
  9. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #9
    Should I just do something like:

    Instead of the java alert & redirect?
     
    amelen, Nov 15, 2007 IP
  10. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #10
    You can use the redirect, just make sure you use exit; or die(), so the actual script stops executing.
     
    nico_swd, Nov 15, 2007 IP
  11. amelen

    amelen Active Member

    Messages:
    686
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #11
    Good point. Thanks again nico_swd!
     
    amelen, Nov 15, 2007 IP