<?php
if(isset($_POST["sub"]))
{
$email;$comment;$captcha;
if(isset($_POST['email'])){
$email=$_POST['email'];
}
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$secretKey = " enter your secret key here..";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>123</h2>';
} else {
echo '<h2>.</h2>';
}
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
require("connection.php");
// Check connection
if($con === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$name = mysqli_real_escape_string($con, $_REQUEST['name']);
$email = mysqli_real_escape_string($con, $_REQUEST['email']);
$country = mysqli_real_escape_string($con, $_REQUEST['country']);
$mobile = mysqli_real_escape_string($con, $_REQUEST['mobile']);
// attempt insert query execution
$sql = "INSERT INTO subscriber (name,email,country,mobile) VALUES ('$name', '$email','$country','$mobile')";
if(mysqli_query($con, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($con);
}
// close connection
mysqli_close($con);
}
?>