Help with PHP Form Mail IP Logging

I have the below code processing my form:

<?php // if the url field is empty if(isset($_POST['url']) && $_POST['url'] == ''){ // put your email address here $youremail = '[email protected]'; // prepare message $body = "You have got new message from your website : Name: $_POST[name] Email: $_POST[email] Subject: $_POST[subject] Message: $_POST[message]"; if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) { $headers = "From: $_POST[email]"; } else { $headers = "From: $youremail"; } mail($youremail, 'Message from Zarin Tasnim Website', $body, $headers, $ip ); } ?>

[b]I want to log the real IP of the person sending the form data from my website.

Please help with the code needed for that.

Thank you![/b]

[php]$ipAddress = $_SERVER[‘REMOTE_ADDR’];
if (array_key_exists(‘HTTP_X_FORWARDED_FOR’, $_SERVER)) {
$ipAddress = array_pop(explode(’,’, $_SERVER[‘HTTP_X_FORWARDED_FOR’]));
}[/php]

Thank you very much for ur reply.

Can u plz make the full code for me as I receive the IP in the email I receive. Plz help! I’m amateur in PHP

You know, you don’t get better when others do your work for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service