954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with IPs

I need some help. I want to make a secure loginsystem and here is my script for the system that checks how many times you tried to login ($try). db.php is the script for connecting with my database. The system isn't in connecton with the loginsystem it is only the part where it checks how many have times you tired to login. If the IP isn't existing, the system will add the IP but if the IP doesn't exist he also adds the IP. Then I have the IP twice in my database. Please help me.

<?php 
include("db.php"); /*connect with mysql*/
$try = 1 ; /*number of tries you had (it will be updatet if you tries the second time)*/
$ip = $_SERVER[REMOTE_ADDR]; //your IP
$ipz = mysql_query("select IP from IPs where IP = '$ip'"); /*check if your ip is in my database*/
if($ipz == $ip) {
		mysql_query("update IPs set tries = '$try' where IP = '$ip'");
}
else {
	mysql_query("insert into IPs values('$_SERVER[REMOTE_ADDR]', '$try')");
}

?>
Akay2
Newbie Poster
8 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Please restate the key issue. This statement says the same thing twice:
" If the IP isn't existing, the system will add the IP but if the IP doesn't exist he also adds the IP."

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

Sorry i write it wrong i mean:
If the IP isn't existing, the system will add the IP but if the IP does exist he also adds the IP

Akay2
Newbie Poster
8 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Check the manual for mysql_query. It returns a resource it doesn't return a field.

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

thx

Akay2
Newbie Poster
8 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: