Annoying: mail() sending duplicate emails.

Discussion in 'PHP' started by themlife, Mar 11, 2008.

  1. #1
    I have a very simple "report link" feature on my site so visitors can let me know if the links are dead. The script below has worked fine until recently. Now when someone reports a link it gets reported 2-3 times. Is it my server or do I need to add something to the code? Thanks!

    
    <?php
    $link = $_GET['link'];
    $ip = $_GET['ip'];
    $email = "myemail@email.com";
    $subject = "Reported Link";
    $body = "The page $link has been reported. IP $ip";
    mail($email, $subject, $body);
    ?>
    
    PHP:
     
    themlife, Mar 11, 2008 IP
  2. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe you should use post variables instead of get variables. It kind of sounds like people are refreshing the page...
     
    Altari, Mar 11, 2008 IP
  3. themlife

    themlife Peon

    Messages:
    105
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I thought people might be refreshing but when I tested it myself it was doing the same thing.
     
    themlife, Mar 11, 2008 IP
  4. mutley

    mutley Peon

    Messages:
    356
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    is this all the code that you are using
     
    mutley, Mar 12, 2008 IP
  5. andy@pmr

    andy@pmr Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You may need to return to the previous page with the header() function to prevent the refreshing..

    The code is too simple and unsafe, make sure to write a better one.
     
    andy@pmr, Mar 12, 2008 IP