• Hello,

    I have had the following form for years, and it has always worked, until about a year ago when Google took over Captcha, or whatever happened in that arena.

    https://www.lh-productions.com/av/?page_id=10

    I’ve managed to update my Captcha keys, but the emails still disappear into cyberspace, i.e. I never receive any of them. The form submit page came with my AV 1.0 Theme. This is currently what’s displayed on the Contact Page Template. There is also a ajaz.recaptcha.php, as well as a recaptchalib.php

    I am not a designer, just had to take over after the guy I hired to do WordPress dropped off the face of the planet. Any direction is appreciated.

    Thanks!

    ————————————

    <?php
    /*
      Template Name: contact
     */
    require_once "recaptchalib.php";
    $publickey = "MY KEY IS HERE"; // you got this from the signup page
    $privatekey = "MY OTHER KEY IS HERE";
    if ($_POST['btnQuoteRequest']) {
        echo $_POST['txtName'] . "";
        $name = $_POST['txtName'];
        $companyName = $_POST['txtComName'];
        $email = $_POST['txtemail'];
        $phone = $_POST['txtPH'];
        $contnet = $_POST['txstDescription'];
        $to = "MY EMAIL IS HERE";
        $subject = "Contactus: " . $_POST["txtName"];
        $message = $contnet;
        $from = $_POST["txtemail"];
        $phone = "phone :" . $_POST["txtPH"] . "\r\n";
        $headers = "From:  $from";
        $msg = $phone . $message;
        if (mail($to, $subject, $msg, $headers)) {
            echo "Email Sent";
        } else {
            echo "Email not Sent";
        }
    }
    get_header();
    ?>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.validate.js"></script>
    <div class='contactBox'>
        <div class='contactBoxtop'><div class="innerRight"><div class="innertTop"></div></div></div>
        <div class='contactBoxcontent'>
            <h1>Quote Request</h1>
            <p style="color:#000;">This form and any attached document are transmitted securely and treated confidentially</p>
            <form action="<?php echo $PHP_SELF;?>" method="post" enctype="multipart/form-data" id="frmContactus" onsubmit="return validateCaptcha();">
                <div class="label"><label>Your Name: <span>*</span></label></div>
                <div class="input"><input type="text" class="required" name="txtName"></div>
                <div class="label">Company/Organization <span>*</span></div>
                <div class="input"><input type="text" class="required" name="txtComName"></div>
                <div class="label"><label>Your Email: <span>*</span></label></div>
                <div class="input"><input type="text" class="required email" name="txtemail"></div>
                <div class="label"><label>Phone number: (Numerals only, no dashes, spaces or characters)</label></div>
                <div class="input"><input type="text" class="txtPH number" name="txtPH"></div>
                <div class="label"><label>Description <span>*</span></label></div>
                <div class="input"><textarea id="txstDescription" class="required" name="txstDescription" cols="55" rows="8"></textarea></div>
    
                <div id="input">
                    <div id="fileInput" style="margin-bottom:10px;">
                        <div class="input" style="margin-bottom:0px;"><input type="file" class="txtfile" name="txtfile"></div>
                        <div class="label"><label>Optionally attach a document (up to 10MB)</label></div>
                    </div>
                    </div>
                    <div id="captchareg">
                            <p><?php echo recaptcha_get_html($publickey);?></p>
                            <p style="color: red;" id="captchaStatus">?</p>
    
                        </div>
                    <div id="btnControl"><input type="reset" name="btnReset" id="btnReset" value="">
                        <input type="submit" name="btnQuoteRequest" id="btnQuoteRequest" value=""></div>
    
            </form>
    
        </div>
        <div class='contactBoxbottom'><div class="innerRight"><div class="innertBottom"></div></div></div>
    </div>
    <div class='contactRBox'>
        <div class='contactRBoxtop'><div class="innerRight"><div class="innertTop"></div></div></div>
        <?php echo $post->post_content; ?>
        <div class='contactRBoxbottom'><div class="innerRight"><div class="innertBottom"></div></div></div>
    </div>
    <script type="text/javascript">
        jQuery("#frmContactus").validate({
    
        });
    </script>
    <script type="text/javascript">
        function validateCaptcha()
        {
            challengeField = $("input#recaptcha_challenge_field").val();
            responseField = $("input#recaptcha_response_field").val();
            //alert(challengeField);
            //alert(responseField);
            //return false;
            var html = $.ajax({
                type: "POST",
                url: "<?php echo bloginfo('template_directory');?>/ajax.recaptcha.php",
                data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
                async: false
            }).responseText;
    
            if(html == "success")
            {
                $("#captchaStatus").html("Success. Submitting form.");
                return true;
                // Uncomment the following line in your application
                //return true;
            }
            else
            {
                $("#captchaStatus").html("Your captcha is incorrect. Please try again");
                Recaptcha.reload();
                return false;
            }
        }
    </script>
    <style type="text/css">
        .recaptchatable #recaptcha_response_field{
            bottom: 2px!important;
            height: 25px;
    }
    .contactBoxcontent p{
        margin: 5px 0 5px 0;
    }
    </style>
    <?php get_footer(); ?>

    [Please, please use the code buttons when posting code here – your code may have been damaged by the forums parser]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Basically, this code has two issues with it that I can see:

    1) It “spoofs” the FROM field in the header by putting a user-provided value in that field, which is the same thing that spammers do when they send fraudulent emails. Many shared web hosting accounts will prevent emails from being sent if the FROM field doesn’t match an email address from a domain being hosted on one of their servers.

    2) It’s using the generic PHP mail function, instead of the wp_mail function in WordPress, so even if you tried to do something like install an SMTP configuration plugin, it wouldn’t help because there’d be no hook for the plugin with which it could interact.

    Thread Starter lhproductions

    (@lhproductions)

    Hmm…interesting. I wonder why it worked, literally, for years, then stopped all of a sudden.

    Do you think the best solution is to rewrite this code, or install other plugins?

    Thread Starter lhproductions

    (@lhproductions)

    > I wonder why it worked, literally, for years, then stopped all of a sudden.

    You are asking me to speculate with insufficient information, but I’d say your web hosting company probably implemented some anti-spam rules on their mail servers that were not there before.

    > Do you think the best solution is to rewrite this code, or install other plugins?

    First I’d see if the author of the AV Theme has issued any updates/patches for the theme. If you are having this issue, chances are others have as well. He/She may have already fixed it.

    If the theme author is no longer around to put out any updates, then you may have to consider modifying code. Just to be clear, modifying code takes you out of any upgrade path in the future, unless you had the foresight to make this a child theme. (Doesn’t look that way, based on what I am able to see, however.)

    Could you do it with another plugin? Yes, in all likelihood. I personally prefer Contact Form 7, and have used that in combination with an STMP Configuration plugin to deal with similar web hosting situations.

    Thread Starter lhproductions

    (@lhproductions)

    First, thanks for your feedback, ideas and analysis.

    The developers of the theme I use seem to be a theme-farm out of Asia. There have never been any updates. Other than this issue, the theme has worked beautifully for me, so I’d like not to change it.

    I actually looked up Contact Form 7 a few days ago and liked what I saw. I wasn’t sure how to go about replacing the built-in elements, but I imagine it will turn out to be pretty easy.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Form submit not sumbitting’ is closed to new replies.