Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ('recaptchalib.php');
- $to = 'alanzvinicius@gmail.com';
- $subject = $_REQUEST['name'];
- $email = $_REQUEST["email"];
- $message = $_REQUEST['comments'] ;
- $header = "from:$email\n";
- $header.= "MIME-Version: 1.0\r\n";
- $header.= "Content-Type: text/plain; charset=utf-8\r\n";
- $header.= "X-Priority: 1\r\n";
- // sua chave secreta
- $secret = "6LcZlxwUAAAAANn6mg8RK-tB1fl3ozGwAlxuO2hd";
- // resposta vazia
- $response = null;
- if ($_POST["g-recaptcha-response"]) {
- $response = $reCaptcha->verifyResponse(
- $_SERVER["REMOTE_ADDR"],
- $_POST["g-recaptcha-response"]
- );
- }
- else{
- $response = null;
- }
- // verifique a chave secreta
- $reCaptcha = new ReCaptcha($secret);
- if ($response != null && $response->success){
- $envioEmail = mail($to,$subject,$message,$header);
- if ($envioEmail){
- echo "<script> alert(' Menssagem enviada com sucesso!'); window.history.go(-1); </SCRIPT>\n";
- }
- else
- {
- echo "<script> alert(' Error ao enviar menssagem!'); window.history.go(-1); </SCRIPT>\n";
- }
- }
- else {
- echo "<script> alert(' Verifique o captcha!'); window.history.go(-1); </SCRIPT>\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement