<!DOCTYPE html>
<html>
<head>
<title>
Google Captcha Form With Send Mail
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<form id="contactform" action="action.php" method="post" class="form" role="form">
<div class="form-group">
<div class="row">
<div class="col-lg-3">
<label>Name:</label>
</div>
<div class="col-lg-5">
<input class="form-control required" id="vname" name="vname" placeholder="Your Name" type="text" required />
</div>
</div>
</div>
<br>
<div class="form-group">
<div class="row">
<div class="col-lg-3">
<label>Email:</label>
</div>
<div class="col-lg-5">
<input class="form-control required" id="vemail" name="vemail" placeholder="Your Email" type="email" required />
</div>
</div>
</div>
<br>
<div class="form-group">
<div class="row">
<div class="col-lg-3">
<label>Information:</label>
</div>
<div class="col-lg-5">
<textarea type="text" name="msg" id="msg" rows="5" cols="50" class="form-control"></textarea>
</div>
</div>
</div>
<br>
<div class="form-group">
<div class="row">
<div class="col-lg-3">
<label>Verify Whether Human</label>
</div>
<div class="col-lg-5">
<div class="g-recaptcha" data-sitekey="PRIVATE" class="form-control">
</div>
</div>
</div>
</div>
<br>
<div class="form-group">
<input type="submit" class="btn btn-success form-send" value="Send">
</div>
</form>
<script src="js/jquery.min.js"></script>
<script src="js/recaptcha.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
and here is the following php
<?php
$captcha;
if (isset($_POST['g-recaptcha-response'])) { $captcha = $_POST['g-recaptcha-response']; }
// Check for correct reCAPTCHA
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret='PRIVATE'&response=" . $captcha . '&remoteip=' . $_SERVER['REMOTE_ADDR']);
if (!$captcha || $response.success == false) {
echo "Your CAPTCHA response was wrong";
exit ;
} else {
// Check for Blank Fields..
if ($_POST["vname"] == "" || $_POST["vemail"] == "" || $_POST["msg"] == "") {
echo "Please fill all required fields";
} else {
// Check if the "Sender's Email" input field is filled out
$email = $_POST['vemail'];
// Sanitize E-mail Address
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$email) {
echo "Invalid Sender's Email";
} else {
$to = 'jinam@evoplus.in';
$subject = 'New Form Entry';
$message = "New message was submitted from <br /> " . "<strong>" . $_POST['vname'] . "</strong>" . "<br /><br />The message is:<br />" . "<strong>" . $_POST['msg'] . "</strong>";
$headers = "From:" . $_POST['vname'] . "<" . $email . ">";
$headers .= "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=UTF-8" . "
";
// Sender's Email
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70, "
");
// Send Mail By PHP Mail Function
if (mail($to, $subject, $message, $headers)) {
echo "Your mail has been sent successfully!";
} else {
echo "Failed to send email, try again.";
exit ;
}
}
}
}
?>
Notice: Use of undefined constant success - assumed 'success' in C:\xampp\htdocs\captchaform\action.php on line 6
i am getting this error help me with this i triend decoding with json no help so where am i wrong