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')");
}

?>

Recommended Answers

All 4 Replies

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."

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

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

thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.