How do I check if an ip is in the database?
I’m creating a little voting system and right now people can vote more than once.
So i put thier Ip in the database and if its already in the database dont want it to allow the upvote. I get the ips in the database using:
$check = mysql_query("SELECT `ip` FROM `voted`") or die(mysql_error());
I just don’t know how to check if the ip that person is voting with is already entered.
Take a look at the
WHEREclause in MySQL:http://www.tizag.com/mysqlTutorial/mysqlwhere.php
Remember– sanitize your inputs. Personally, I would use parameters and bindings, but if you are going plain-vanilla MySQL then just use the escaping function. But remember, the
mysql_functions are being deprecated, so I would avoid them if possible. (See PDO)