Recaptcha help needed for newbie

Hi there, not a coder here but looking for help with recaptcha. I’ve got the code placed on my html form page but need help in making it work on this php page (I assume is where it needs to go) any help is appreciated:

    $recipient = '[email protected]';
	//$recipient = '[email protected]';

	//SMTP server settings	
	$host = 'mail.website.ca';
    $port = '587';//"587";
    $username = 'ouruser';
    $password = 'ourpassword';

    $user_email='';    
	$message_body='';
	$message_type='html';


try {
    require './phpmailer/PHPMailerAutoload.php';


    $mail = new PHPMailer();
    $mail->SMTPDebug = 0;

    # 
    # Set up connection parameters.
    #
    $mail->isSMTP();
    $mail->Host = $host;
    $mail->Port = $port;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Username = $username;
    $mail->Password = $password;

    #
    # Set up the mail headers.
    #
    $mail->From = '[email protected]';
    $mail->FromName = "Our Website";
    $mail->addAddress($recipient);


    #
    # Build the contents of the mail message.
    #
    $mail->isHTML(false);
    $mail->CharSet = 'utf-8';
    $mail->Subject = 'Contact form for '.$_POST['Name'];

    $body = "City: ".$_POST['City']."\n";
    $body .= "Telephone: ".$_POST['Telephone']."\n";
    $body .= "Email: ".$_POST['Email']."\n\n";
    $body .= "=== Comments ===\n";
    $body .= $_POST['Comments']."\n";
    $mail->Body = $body;

    #
    # Send the message.
    #
    $mail->send();
	header("Location:/contact_thanks.html");

    die('MF000');
} catch (phpmailerException $e) {
    die('MF254');
} catch (Exception $e) {
    die('MF255');
}

This code looks like it’s sending an email - not printing anything out to the screen. This script will be targeted by another somewhere on your site. That script is where you need to put the recaptcha. You’re looking for a file with a <form> tag in it; something like:

<form method="post" action="[something]">

where [something] is the name of the file you pasted above. Once you’ve found that file, you should be able to add the recaptcha to it in the same way you added it to your HTML file.

thanks for your response - this is the html file with the form on it - would it go on this page? Again I’m not super code savvy if you could give a bit of help with what code would go where? Thanks:

                                      <tr class="mntext">
                                        <td colspan="2" class="regtext"><img src="images/spacer.gif" width="5" height="15" /></td>
                                      </tr>
                                      <tr class="mntext">
                                        <td class="regtext"><div class="g-recaptcha" data-sitekey="6LeQ2b...my site key"></div>
                                        </td>
                                        <td class="regtext"><input type="submit" class="bodytext" value="Submit" />
                                            <input type="reset" class="bodytext" value="Clear" />                                            </td>
                                      </tr>
                                      <tr class="mntext">
                                        <td colspan="2" class="regtext"><img src="images/spacer.gif" width="5" height="15" /></td>
                                      </tr>
                </table>
              </form>
Name:
City:
Tel:
Email Address:
Comments:

That’s the one. It should go on there in the same way you put it on the HTML page you first tried.

Thanks again I’m just a bit confused - does the code I need to include (somewhere) not have the private captcha code? This would not go on the the same html page as the form… as it holds the public code… Unfortunately I really do need help in knowing exactly what the actual code is I need to use and what page it is to go on (and where) sorry but I really do appreciate the help!

Sponsor our Newsletter | Privacy Policy | Terms of Service