We help IT Professionals succeed at work.
Get Started

PHP IP Logging Question

wantabe2 asked
Last Modified: 2012-05-11
Is there any way for me to edit this code so I can somehow log all attempts to log into this system? This code currently displays the IP address at the bottom of the login page....but is there any way I can log this somewhere or log unsuccessful & successful logons?
<body bgcolor="#03EBA6"> 



// username and password sent from Form 


$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";

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


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


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

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

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

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

<input type="submit" value=" Login "/><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>


<center><b>Your IP Address is: </b><?php echo $_SERVER["REMOTE_ADDR"]; ?></center>

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE