A form was compromised on my website. Because writing code is not my forte, this code was given to me to prevent users from using the form more than once and overloading the database and server.
The problem is, it doesn't seem to work. Instead it seems to generate two emails to the admin and two entries to the table on the database.
What do I need to change to make it work?
mysql_connect($mysql_server, $mysql_username, $mysql_password) or die('Failed to connect to database server!<br>'.mysql_error());
mysql_select_db($mysql_database) or die('Failed to select database<br>'.mysql_error());
$result = mysql_query("SELECT * FROM $mysql_table WHERE IP = $_SERVER[REMOTE_ADDR]");
if ($data = mysql_fetch_array($result))
{
if ($data['IP'] == $_SERVER[REMOTE_ADDR])
{
header('Location: '.$error_url);
exit;
}
}
mysql_close();