I have a form
, and a table
inside of it. I wanted to add reCaptcha, but the form-check is not receiving the $_POST
value for the reCaptcha. Here is my form:
<form name="reg" action="code_exec.php" onsubmit="return validateForm()" method="post">
<td colspan="2">
<div align="center">
<h1>Register</h1>
</div></td>
</tr>
<tr>
<td colspan="2"><center><p style="font-family: Arial; font-size: 18px; color: red;">*<span style="color: red; font-family: Arial; font-size: 14px;">Required</span></p></center></td>
</tr>
<tr>
<td><div align="right">Name:<span class="red">*</span></div></td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td><div align="right">Username:<span class="red">*</span></div></td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td><div align="right">E-mail:<span class="red">*</span></div></td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><div align="right">Password:<span class="red">*</span></div></td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><div align="right">Confirm Password:<span class="red">*</span></div></td>
<td><input type="password" name="passwordconf" /></td>
</tr>
<tr>
<td></td>
<td><div class="g-recaptcha" data-sitekey="6LfDzgITAAAAABkYv1oZe4X7Sy3OqYmk4hQQBMHz"></div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><input name="submit" type="submit" value="Submit" /></td>
</tr>
<tr>
<td></td>
<td><br><a href="../login">Log In</a>
</tr>
<tr>
<td><div align="right"></div></td>
<td><input type="text" name="captchaid" style="visibility: hidden;" value="<?php echo $captchaid?>" /></td>
</tr>
</table>
</table>
</form>
and here is my code_exec.php:
$captcha=$_POST['g-recaptcha-response'];
var_dump($_POST);
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LfDzgITAAAAAD-l4TY_v6Tnqtb8Y0mtEB-HjApC&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false) {
//do stuff
}
else {
//process form
}
The problem is, after var_dump($_POST)
, the g-recaptcha-response
doesn't show up. Any solutions?
</div>