Welcome! Log In Create A New Profile

Advanced

IP Address

Posted by Shaun2010 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar IP Address
April 19, 2011 07:09AM
Just abit of code that I was playing with, what I basically want it to do is check a users ip against my ip table and if it is the first time the user visits the site capture the ip and display a message, if it's a known ip do something else and not capture it. When I run that code it captures the ip even if it is already in my table.

Language: PHP
$ip = $_SERVER[';REMOTE_ADDR';]; $ip_query = "SELECT ip_address FROM ip"; $result = mysql_query($ip_query); while ($row = mysql_fetch_array($result)){ $known_ip = $row[';ip_address';];   if ($ip != $known_ip) { $ip_insert = "INSERT INTO ip (ip_address) VALUES (';$ip';)"; $result2 = mysql_query($ip_insert); echo "Unknown IP"; } else {   }

A word to the wise ain't necessary - it's the stupid ones that need the advice.
Student Number:72793775
Sorry, only registered users may post in this forum.

Click here to login