<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Using Recaptcha code</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Using-Recaptcha-code-78990</link>
        <description></description>
        <pubDate>Tue, 14 Apr 2026 08:29:50 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Using-Recaptcha-code-78990" rel="self" type="application/rss+xml" />

                <item>
          <title>Using Recaptcha code</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231699#post2231699</link>
          <description><![CDATA[<p>Hi,</p>
<p>You'll want to use the code you have after the "<span>// process form" after you've checked the recaptcha code.</span></p>
<p>A good approach would be something like this:</p>

<p><code> if (@$_REQUEST['submitForm']) {<br /><br />    // error checking<br /><br />    $errorsAndAlerts = "";<br /><br />    if (!@$_REQUEST['fullname'])                { $errorsAndAlerts .= "You must enter your full name!&lt;br/&gt;\n"; }<br /><br />    if (!@$_REQUEST['email'])                   { $errorsAndAlerts .= "You must enter your email!&lt;br/&gt;\n"; }<br /><br />    else if(!isValidEmail(@$_REQUEST['email'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)&lt;br/&gt;\n"; }<br /><br />               if (!@$_REQUEST['country'])                 { $errorsAndAlerts .= "You must enter a value for country!&lt;br/&gt;\n"; }<br /><br />               if (!@$_REQUEST['message'])                { $errorsAndAlerts .= "You must enter a message!&lt;br/&gt;\n"; }<br /><br />  require_once('recaptchalib.php');<br /><br />  $privatekey = "your_private_key";<br /><br />  $resp = recaptcha_check_answer ($privatekey,<br /><br />                                $_SERVER["REMOTE_ADDR"],<br /><br />                                $_POST["recaptcha_challenge_field"],<br /><br />                                $_POST["recaptcha_response_field"]);<br /><br /><span style="color:#0000ff;">  if (!$resp-&gt;is_valid) {</span><br /><br /><span style="color:#0000ff;">    // What happens when the CAPTCHA was entered incorrectly</span><br /><br /><span style="color:#0000ff;">    $errorsAndAlerts .= "The reCAPTCHA wasn't entered correctly. Go back and try it again.";</span><br /><br /><br /><span style="color:#0000ff;">  } </span><br /><br /></code></p>
<p>In this way, the recaptcha checking becomes part of the normal error checking on the form.</p>

<p>Hope this helps.</p>

]]></description>
          <pubDate>Thu, 05 Sep 2013 12:10:01 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231699#post2231699</guid>
        </item>
                <item>
          <title>Using Recaptcha code</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231694#post2231694</link>
          <description><![CDATA[<p><b>Hi</b></p>
<p><b>I wanted to add the google recaptcha code to an enquiry form I have.</b></p>
<p><b>The code for the form in headers I have is:</b></p>
<p>&lt;?php header('Content-type: text/html; charset=utf-8'); ?&gt;</p>
<p>&lt;?php</p>
<p>  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */</p>
<p>  // load viewer library</p>
<p>  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';</p>
<p>  $dirsToCheck = array('/home/domain/public_html/domain.com/','','../','../../','../../../');</p>
<p>  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}</p>
<p>  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }</p>
<p>   list($officeRecords, $officeMetaData) = getRecords(array(</p>
<p>    'tableName'   =&gt; 'office',</p>
<p>  ));</p>
<p>  // load records</p>
<p>// process form</p>
<p>  if (@$_REQUEST['submitForm']) {</p>
<p>    // error checking</p>
<p>    $errorsAndAlerts = "";</p>
<p>    if (!@$_REQUEST['fullname'])                { $errorsAndAlerts .= "You must enter your full name!&lt;br/&gt;\n"; }</p>
<p>    if (!@$_REQUEST['email'])                   { $errorsAndAlerts .= "You must enter your email!&lt;br/&gt;\n"; }</p>
<p>    else if(!isValidEmail(@$_REQUEST['email'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)&lt;br/&gt;\n"; }</p>
<p>               if (!@$_REQUEST['country'])                 { $errorsAndAlerts .= "You must enter a value for country!&lt;br/&gt;\n"; }</p>
<p>               if (!@$_REQUEST['message'])                { $errorsAndAlerts .= "You must enter a message!&lt;br/&gt;\n"; }</p>
<p>    // send email user</p>
<p>    if (!$errorsAndAlerts) {</p>
<p>      $from    = $_REQUEST['email'];</p>
<p>      $to      = "info@domain.com";</p>
<p>      $subject = "Email form submitted";</p>
<p>      $message = &lt;&lt;&lt;__TEXT__</p>
<p>You've received an email enquiry</p>
<p>Full name: {$_REQUEST['fullname']}</p>
<p>Country: {$_REQUEST['country']}</p>
<p>Phone: {$_REQUEST['telephone']}</p>
<p>Email:     {$_REQUEST['email']}</p>
<p>Message:   {$_REQUEST['message']}</p>
<p>The user who sent this message had the IP address {$_SERVER['REMOTE_ADDR']}.</p>
<p>__TEXT__;</p>
<p>      // Note: The above line must be flush left or you'll get an error</p>
<p>      // This is a PHP heredoc.  See: <a href="http://ca2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc" rel="nofollow">http://ca2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc</a></p>
<p>      // send message</p>
<p>      $mailResult = @mail($to, $subject, $message, "From: $from");</p>
<p>      if (!$mailResult) { die("Mail Error: $php_errormsg"); }</p>
<p>      //</p>
<p>       redirectBrowserToURL('/confirm.php?success='.urlencode('Thank you for your enquiry. '));</p>
<p>    $_REQUEST = array(); // clear form values</p>
<p>    exit;</p>
<p>    }</p>
<p>  }</p>
<p>?&gt;</p>

<p><b>The first line on the form is:</b></p>
<p>&lt;form method="post" action="?"&gt;</p>
<p><b>The instructions on recaptcha are to change this to:</b></p>
<p>&lt;form method="post" action="verify.php"&gt;</p>
<p><b>The code for verify.php is:</b></p>
<p>&lt;?php</p>
<p>  require_once('recaptchalib.php');</p>
<p>  $privatekey = "your_private_key";</p>
<p>  $resp = recaptcha_check_answer ($privatekey,</p>
<p>                                $_SERVER["REMOTE_ADDR"],</p>
<p>                                $_POST["recaptcha_challenge_field"],</p>
<p>                                $_POST["recaptcha_response_field"]);</p>

<p>  if (!$resp-&gt;is_valid) {</p>
<p>    // What happens when the CAPTCHA was entered incorrectly</p>
<p>    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .</p>
<p>         "(reCAPTCHA said: " . $resp-&gt;error . ")");</p>
<p>  } else {</p>
<p>    // Your code here to handle a successful verification</p>
<p>  }</p>
<p>  ?&gt;</p>

<p><b>At the point where is says </b>// Your code here to handle a successful verification<b> do I need to copy some of the code I have in my header over to verify.php? If so what should I copy over?</b></p>
<p><b>Thanks</b></p>
]]></description>
          <pubDate>Thu, 05 Sep 2013 03:00:44 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231694#post2231694</guid>
        </item>
              </channel>
    </rss>
  