SHARE
TWEET

Untitled

a guest Mar 25th, 2016 520 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(isset($_POST['email'])) {
  2.     $email_to = "info@preprosto.com";
  3.     $email_subject = "Sporočilo s spletne strani";
  4.  
  5.    
  6.     function died($error) {
  7.         echo "Napaka!";
  8.         echo $error."<br /><br />";
  9.         die();
  10.     }
  11.  
  12.    
  13.     if(!isset($_POST['email']) ||
  14.        !isset($_POST['name']) ||
  15.        !isset($_POST['message']) ) {
  16.             died('Napaka! Preverite vaše vnose.');        
  17.     }
  18.  
  19.      
  20.     $email = $_POST['email'];
  21.     $name = $_POST['name'];
  22.     $message = $_POST['message'];
  23.  
  24.      
  25.     $email_message = "E-mail message:\n\n";
  26.  
  27.    
  28.     function clean_string($string) {
  29.  
  30.       $bad = array("content-type","bcc:","to:","cc:","href");
  31.  
  32.       return str_replace($bad,"",$string);
  33.  
  34.     }
  35.  
  36. function getUserIpAddr()
  37. {
  38.     if (!empty($_SERVER['HTTP_CLIENT_IP']))
  39.     {
  40.         return $_SERVER['HTTP_CLIENT_IP'];
  41.     }
  42.     else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  43.     {
  44.         return $_SERVER['HTTP_X_FORWARDED_FOR'];
  45.     }
  46.     else
  47.     {
  48.         return $_SERVER['REMOTE_ADDR'];
  49.     }
  50. }    
  51.     $email_message .= "IP: ".getUserIpAddr()."\n";
  52.    
  53.     $email_message .= "Name: ".clean_string($name)."\n";
  54.     $email_message .= "E-mail: ".clean_string($email)."\n";
  55.  
  56.     $email_message .= "Message: ".clean_string($message)."\n";
  57.  
  58.  
  59.  
  60. $headers = "MIME-Version: 1.0" . "\r\n";
  61. $headers .= "Content-type:text/plain;charset=UTF-8" . "\r\n";
  62. $headers .= 'From: '.$email. "\r\n";
  63.  
  64. if (@mail($email_to, $email_subject, $email_message, $headers)) {
  65.     header('Location: message-thankyou.html');
  66. } else {
  67.     header('Location: message-error.html');
  68. }
  69.  
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top