I am trying to add recaptcha into my custom PHP form and am confused about how to do so. Recaptcha requires adding recaptchalib.php into the form, but if I add verify.php then my form will not process, as I am using my PHP file to process my form.
<form method="POST" action="process.php" id="form-ok"> The documentation is a bit confusing. My question is, what do I need to do to process two actions?
Any idea how can I get this working?
Process.php
<?php $redirectTo = '/thankyou.html'; $subject = 'New message from site'; // Email SUBJECT field $receive = array( '[email protected]' ); if($_POST['email_check'] == '') { if (isset($_POST['first_name'])){ $message = '<table width="100%" border="0" cellspacing="0" cellpadding="8" style="border:1px solid #f3f3f3"> <tr> <td colspan="3" height="30" style="font-size:20px"><strong>' . $subject . '</strong></td> </tr> <tr> <td width="100" bgcolor="#f3f3f3"><strong>First Name: </strong></td> <td width="14" height="30" bgcolor="#f3f3f3"> </td> <td width="305" bgcolor="#f3f3f3">' . $_POST ['first_name'] . '</td> </tr> <tr> <td><strong>Last Name: </strong></td> <td width="14" height="30"> </td> <td>' . $_POST ['last_name'] . '</td> </tr> <tr> <td bgcolor="#f3f3f3"><strong>Email: </strong></td> <td bgcolor="#f3f3f3" width="14" height="30"> </td> <td bgcolor="#f3f3f3">' . $_POST ['email'] . '</td> </tr> <tr> <td><strong>Phone Number: </strong></td> <td width="14" height="30"> </td> <td>' . $_POST ['phone'] . '</td> </tr> <tr> <td bgcolor="#f3f3f3"><strong>Check: </strong></td> <td bgcolor="#f3f3f3" width="14" height="30"> </td> <td bgcolor="#f3f3f3">'; foreach($_POST['role'] as $value) { $message.=$value.'<br>'; } $message.='</td> </tr> <tr> <td><strong>Message: </strong></td> <td width="14" height="30"> </td> <td>' . $_POST ['message'] . '</td> </tr> <tr> <td><strong>Referer:</strong></td> <td width="14" height="30"> </td> <td>' . $_SERVER ['HTTP_REFERER'] . '</td> </tr> <tr> </table>'; for ($i = 0; $i < count($receive); $i++){ $to = $receive[$i]; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; $headers .= 'From: ' . $_POST['email'] . "\n" . 'Reply-To: ' . $_POST['email'] . "\n"; mail($to, $subject, $message,$headers); } header('Location: '.$redirectTo); } } else{ header('Location:'.$_SERVER['HTTP_REFERER']); die(); } ?>
process.php, and run it as part of your default form processing. It's a single action, since the ReCAPTCHA information is submitted as part of the form.