I'm trying to make a song request form for a radio station but they do not want spamming. I've done the form etc which is pretty simple but I am trying to make it so... If a visitor requests a song, that request will be stored in a database so the DJ can check it. I want it so the DJ will have to click Played to allow the same visitor request again, else it will not allow that same IP to request again.
The problem is, the checking if the IP is there isn't working.
Here the code, it maybe a easy fix...
<?php include "db.php"; ?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h3> Request a song</h3>
<?
$ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$query = "SELECT * FROM requests WHERE ip='". $_SERVER['REMOTE_ADDR'] ."'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
echo "<form action='thankyou.php' method='post'>
Your Name:<br>
<input type='text' name='name' required><br>
Artist:
<input type='text' name='artist' required><br>
Song:<br>
<input type='text' name='song' required><br>
Message:<br>
<input type='text' name='message' required><br>
<input type='submit' value='Submit'><br>
</form>";
}
else {
echo "Your song hasn't been played yet.";
}
?>
</body>
</html>
Thanks in advance.