Image Captcha has messed up php email form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sld87
    New Member
    • Mar 2008
    • 2

    Image Captcha has messed up php email form

    Hi guys, (Newbie member here!)

    Having some serious difficulty getting our php email system working after implementing an image captcha to stop the hundreds of bots spamming it.

    I may as well post the src first:

    Subscription Form:

    Code:
    <form action="newsletter.php" method="post" enctype="multipart/form-data" name="form" id="form">
                                                            <label>Your Email Address:
    
                                                              <input type="addemail" name="textfield" id="addemail">
                                                            </label>
                                                            <p><img src="CaptchaSecurityImages.php" />
                                                              <br>
                                                              Security Code: 
    <input id="security_code" name="security_code" type="text" />
    <br>
    <input type="submit" name="submit" value="Submit" />
    
    
    <br>
                                                              </p>
                                                          </form>
    PHP File:

    [PHP]<?php
    session_start() ;
    if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSI ON['security_code'])) ) {
    // Insert your code for processing the form here, e.g emailing the submission, entering it into a database.
    $to = "newsletter@boc caccio.com.au";
    $subject = "New Mailing List Entry - $email";
    $email = $_REQUEST['addemail'] ;
    $message = $_REQUEST['message'] ;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {print "Thankyou. Your subscription has been successful. You will now be redirected home..."; }

    echo "<META http-equiv='Refresh' content='5; url=http://www.boccaccio.c om.au'>";

    unset($_SESSION['security_code']);
    } else {
    {print "Incorrect security code. Please try again. You will now be redirected back..."; }
    echo "<META http-equiv='Refresh' content='5; url=http://www.boccaccio.c om.au/join.html'>";
    // Insert your code for showing an error message here
    }
    ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Boccacci o Cellars Newsletter Subscription</title>
    </head>

    <body>

    [/PHP]

    Now, the problem is, i'm suddely only receiving blank emails, when in order for our subscription program to work it needs their email in the subject line and also in the 'from' field.

    Any help appreciated, (You can view the page on www.boccaccio.c om.au/join.htm)

    Cheers.
  • sld87
    New Member
    • Mar 2008
    • 2

    #2
    Hmm, still experimenting. Heres another one, the only problem is i'm having problems nesting the IF statement to verify the image captcha. Its commented out because it works without it in there (But is obviously pointless cause it ignores the captcha)

    [PHP]<?php
    session_start() ;
    // Hello! welcome to the settings page.
    // Here's your two steps guide:

    // FIRST:
    // Instead of newsletter@test .com put the email address of the mailing list,
    // (the same that SendBlaster uses in Manage Subscriptions Section)
    // ... please pay attention to the ' ' apostrophes, they must remain around the email address.

    $emailmanager = 'newsletter@boc caccio.com.au';

    // SECOND:
    // save this file, and close it. Thank you!


    error_reporting (0);

    $email = trim($_POST['email']);
    $Ok = ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email);
    if ($Ok) {

    // {if ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSI ON['security_code'])) )
    mail($emailmana ger,'Subscribe' ,'','From: '.$email);
    //else {alert('Incorre ct image entry. Please try again.');

    if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UName Frm))
    {
    ?>
    <script language = 'javascript'>
    alert('Thank you, your address was added to our Mailing List');
    history.go(-1);
    </script>
    <?
    exit();
    }
    }

    else {
    if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UName Frm))
    {
    ?>
    <script language = 'javascript'>
    alert('Sorry, please provide a valid Email address.');
    history.go(-1);
    </script>
    <?
    exit();
    }
    }
    ?>
    [/PHP]

    Comment

    Working...