Jump to content

IP getya and storeya


eaglelegend

Recommended Posts

Hey all again!, I have just completed a wonderful code that can do more than ban users!!, via IP, however, I cant seem to get the code to "update" the users new IP address when they log in, any ideas?? any help is appreciated! (and then put it in mysql) however it shows as blank, nothing was collected!

 

<?php
include("header.php");

if(isset($_POST['username']) && isset($_POST['password'])) {
                   $username = $_POST['username'];
                   $password = md5($_POST['password']);
                   $ip = getenv(‘REMOTE_ADDR’);
}

if($username && $password) {
$check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`='$username' AND `password`='$password'"));

if($check == 1) {		    
	        $_SESSION['ELv2'] = $username;
	        if(session_register('ELv2')){
 	    $set = mysql_query("UPDATE `members` SET `ip`='$ip' WHERE `username`='{$_SESSION['ELv2']}'");
 	 	Header("Location: index.php");
 	}
 	else {
 	 	print "Cant set cookie";
 	}
}
else {
 	print "Sorry, username/password mismatch!";
}

}
else {
?>
<h2>Login</h2><p>
<form action="login.php" method="post">
Username<br>
<input type="text" name="username" class="text_box" size="20" value="Username" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p>
Password<br>
<input type="password" name="password" class="text_box" size="20" value="password" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p>
<input type="hidden" name="ip" value="set">
<input type="submit" class="text_box" value=" Login " title="Click here to log in." alt="Click here to log in."></form>
<?php
}

include("footer.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/107146-ip-getya-and-storeya/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.