PHP get ip address in network


PHP  How to get ip address in network


<?php

        $userID = $result['userid'];
        $dt = date('Y-m-d G:i:s',time());
        $desc = "Login";
            if (!empty($_SERVER['HTTP_CLIENT_IP']))
            {   //check ip from share internet
                $ip=$_SERVER['HTTP_CLIENT_IP'];
            }
            elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
            {   //to check ip is pass from proxy   
                $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
            }
            else
            {
                $ip=$_SERVER['REMOTE_ADDR'];
            }
   
        $sql2="INSERT INTO userlog(logid,userid,logaction,logipaddr,status,createddate)VALUES('','$userID','$desc','$ip','0','$dt')";
        $res2=mysql_query($sql2);

?>
Share on Google Plus

About quora Questions & Answers A-Z

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment