PHP Code to Log IP Address

wantabe2
wantabe2 used Ask the Experts™
on
Is it possible to add some code to existing php code that will display the users IP address, netbios name, or any other information (mainly the IP address) at the bottom of the screen so the user will see it?
<?php

include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{

// username and password sent from Form 

$myusername=addslashes($_POST['username']); 
$mypassword=addslashes($_POST['password']); 

$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;

header("location: welcome.php");
}
else 
{
$error="Your Login Name or Password is invalid";
}
}

?>

<form action="" method="post">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<center> <h2>Eastern District</h2></center>
<center> <h2> Human Resource Employment Tracking System </h2> </center>
<br>
<br>
<center><label><b>USER NAME :</b></label>

<input type="text" name="username"/><br />

<label><b>PASSWORD :</b></label>

<input type="password" name="password"/><br/>
<br>

<input type="submit" value=" Login "/><br />
</center>
<br>
<br>
<br>
<center> <b> *** The IP address of your computer has already been logged *** </center>
<center> *** All unsuccessful & successful attempts to log onto this system is recorded *** </b> </center>

</form>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IP: :<?php echo $_SERVER["REMOTE_ADDR"]; ?>

You won't get the NetBIOS name as PHP is server side script and cannot access the client machine for that data.

Lee

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial