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 = '';
    $port = '587';//"587";
    $username = 'ouruser';
    $password = 'ourpassword';


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

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

    # Set up connection parameters.
    $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";

    # Build the contents of the mail message.
    $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.

} catch (phpmailerException $e) {
} catch (Exception $e) {

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 class="mntext">
                                        <td class="regtext"><div class="g-recaptcha" data-sitekey=" site key"></div>
                                        <td class="regtext"><input type="submit" class="bodytext" value="Submit" />
                                            <input type="reset" class="bodytext" value="Clear" />                                            </td>
                                      <tr class="mntext">
                                        <td colspan="2" class="regtext"><img src="images/spacer.gif" width="5" height="15" /></td>
Email Address:

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