php - IP Address won't pass to e-mail body -


my php form setup pull ip address sender. form generates no errors...test e-mail received, not pass ip address body of e-mail. did wrong? here php form:

<?php     $owner_email='info@mywebsitedesign.com';     //smtp server settings       $host = '';     $port = '465';//"587";     $username = '';     $password = '';      $subject='my website design';     $user_email='';         $message_body='';     $message_type='html';      $max_file_size=50;//mb      $file_types='/(doc|docx|txt|pdf|zip|rar)$/';     $error_text='something goes wrong';     $error_text_filesize='file size must less than';     $error_text_filetype='failed upload file. file type not allowed. accepted files types: doc, docx, txt, pdf, zip, rar.';      $private_recaptcha_key='6lezwuksaaaaacmqrblmdpvdhc68nlb1c9ea5vzu'; //localhost       $use_recaptcha=isset( $_post["recaptcha_challenge_field"]) , isset($_post["recaptcha_response_field"]);     $use_smtp=($host=='' or $username=='' or $password=='');     $max_file_size*=1048576;      if($owner_email==''){     die('attention, recipient e-mail not set! please define "owner_email" variable in mailhanlder.php file.');     }      if(preg_match('/^(127\.|192\.168\.)/',$_server['remote_addr'])){     die('attention, contact form not work locally! please upload template live hosting server.'); }      if($use_recaptcha){         require_once('recaptchalib.php');         $resp = recaptcha_check_answer ($private_recaptcha_key,$_server["remote_addr"],$_post["recaptcha_challenge_field"],$_post["recaptcha_response_field"]);         if (!$resp->is_valid){             die ('wrong captcha');         }     }      if(isset($_post['name']) , $_post['name'] != ''){$message_body .= '<p>name: ' . $_post['name'] . '</p>' . "\n" . '<br>' . "\n"; $subject.=$_post['name'];}     if(isset($_post['email']) , $_post['email'] != ''){$message_body .= '<p>email address: ' . $_post['email'] . '</p>' . "\n" . '<br>' . "\n"; $user_email=$_post['email'];}     if(isset($_post['company']) , $_post['company'] != ''){$message_body .= '<p>company: ' . $_post['company'] . '</p>' . "\n" . '<br>' . "\n";}       if(isset($_post['topic']) , $_post['topic'] != ''){$message_body .= '<p>topic: ' . $_post['topic'] . '</p>' . "\n" . '<br>' . "\n";}       if(isset($_post['ipaddress']) , $_post['ipaddress'] != ''){$message_body .= '<p>ip address: ' . $_post['ipaddress'] . '</p>' . "\n" . '<br>' . "\n";}     if(isset($_post['message']) , $_post['message'] != ''){$message_body .= '<p>message: ' . $_post['message'] . '</p>' . "\n";}       if(isset($_post['striphtml']) , $_post['striphtml']=='true'){$message_body = strip_tags($message_body);$message_type='text';}  try{     include "libmail.php";     $m= new mail("utf-8");     $m->from($user_email);     $m->to($owner_email);     $m->subject($subject);     $m->body($message_body,$message_type);     //$m->log_on(true);  // function client ip address function get_client_ip_server() {     $ipaddress = '';     if ($_server['http_client_ip'])         $ipaddress = $_server['http_client_ip'];     else if($_server['http_x_forwarded_for'])         $ipaddress = $_server['http_x_forwarded_for'];     else if($_server['http_x_forwarded'])         $ipaddress = $_server['http_x_forwarded'];     else if($_server['http_forwarded_for'])         $ipaddress = $_server['http_forwarded_for'];     else if($_server['http_forwarded'])         $ipaddress = $_server['http_forwarded'];     else if($_server['remote_addr'])         $ipaddress = $_server['remote_addr'];     else         $ipaddress = 'unknown';      return $ipaddress; }      if(isset($_files['attachment'])){     if($_files['attachment']['size']>$max_file_size){         $error_text=$error_text_filesize . ' ' . $max_file_size . 'bytes';         die($error_text);                    }else{                   if(preg_match($file_types,$_files['attachment']['name'])){             $m->attach($_files['attachment']['tmp_name'],$_files['attachment']['name'],'','attachment');         }else{             $error_text=$error_text_filetype;             die($error_text);                            }         }            } if(!$use_smtp){     $m->smtp_on( $host, $username, $password, $port);     }      if($m->send()){     die('success');     }     }catch(exception $mail){ die($mail); }    ?> 

i think no need of if(isset($_post['ipaddress']) , $_post['ipaddress'] != '')

{$message_body .= '<p>ip address: ' . $_post['ipaddress'] . '</p>'   {$message_body .= '<p>ip address: ' .get_client_ip_server() . '</p>' 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -