Results 1 to 6 of 6

Thread: Make my form not spamable and validation of fields?

  1. #1
    Join Date
    Apr 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Make my form not spamable and validation of fields?

    <?

    $name = $_GET['name'] ;
    $email = $_GET['email'] ;
    $text = $_GET['text'] ;

    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $text = $_POST['text'] ;

    mail( "contact@getastranger.com", "Contest", "$name

    EMAIL: $email\n

    $text", "From: $name <$email>\r\n" );

    header( "Location: http://www.homepage.com" );

    ?>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    $name = $_GET['name'] ;
    $email = $_GET['email'] ;
    $text = $_GET['text'] ;

    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $text = $_POST['text'] ;
    If you want register_globals, use register_globals. If you use this code, then if the values are set by $_GET but not by $_POST, then the correct $_GET fields will be overridden by the blank $_POST fields.

    Bot checks are tricky. A simple measure that will severely limit most mailbombing attacks is to use sleep(3); before header() there.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello

    Thank you for your kind reply

    How would I interpret that into my code? I am sadly not so very good at these kinds of things

    When I mean I want to avoid spamming, I guess I would like some sort of code that does not allow more than 1 message/minute from each user.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I guess I would like some sort of code that does not allow more than 1 message/minute from each user.
    Unless you really want to keep a registry of recent IPs, that's not really feasible. Search the Web for some free bot-check scripts.
    PHP Code:
    <?php
      
    // If you do not have permission to use this, use $_POST
      // and $_GET as you were doing, BUT remember to check
      // if the value is set (i.e. isset($_GET['email'])) before
      // gleefully overwriting it.
      
    ini_set('register_globals''on');

      
    $message = <<<EOT
    $name
    EMAIL: 
    $email\n
    $text
    EOT;

      
    mail("contact@getastranger.com""Contest"$message"From: $name <$email>\r\n");
      
    sleep(3);
      
    header("Location: http://www.homepage.com/");
    ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, I will try it out

    How about the check for empty fields?
    I guess I have to use "if" in some way?

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    if($_POST['field'] === "")
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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