Advertisement
markotvz

mail.php sa integriranom captcha provjerom

Jul 23rd, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3.         $email=isset($_POST['email']) ? $_POST['email'] : '';
  4.         $comment=isset($_POST['poruka']) ? $_POST['poruka']: '';
  5.         $captcha;
  6.         $primatelj='midzan21@gmail.com';
  7.         $email = filter_var($email, FILTER_SANITIZE_EMAIL);
  8.         if(isset($_POST['g-recaptcha-response']))
  9.           $captcha=$_POST['g-recaptcha-response'];
  10.  
  11.         if(!$captcha){
  12.           echo '<h2>olim Vas da riješite captchu!</h2>';
  13.           exit;
  14.         }
  15.         $response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=MY_SECRET_CODE&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
  16.         if($response['success'] == false)
  17.         {
  18.           echo '<h2>Spamerima zabranjen pristup!</h2>';
  19.         }
  20.         else
  21.         {
  22.             if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
  23.                 $headers = 'MIME-Version: 1.0' . "\r\n";
  24.                 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  25.                 $headers .= 'Od:' . $email. "\r\n";
  26.                 $headers .= 'Cc:' . $email. "\r\n";
  27.                 mail($primatelj, $email, $headers, $comment);
  28.             }
  29.                 echo '<h2>Vaša poruka je poslana, odgovoriti ću Vam u najkraćem mogućem roku.</h2>';
  30.         }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement