Ok I actually tested this and fixed a few type O's in previous code. It has your php insert stuff in the appropriate.
It seems you do not understand SQL queries from your previous question so before I give you the answer let me tell you a few things. You only need to connect to a database once per script.
The connection to a database is usually the longest part or any sql--> php interaction.
When you say
Select * From TBL
It means that you want all colums from table TBL in the database you should have connected to earlier.
So everything in this code works properly on my test machine except for possibly your command as I didt bother to send pretend post data to it.
<?PHP
$db = mysql_connect("server", "user", "password");
$db_selected =mysql_select_db("db120468699", $db);
if (!$db_selected) {
die ('Cant use foo : ' . mysql_error());
}
// Updated Remote IP to be more fault tollerant for Getting Address.
$RemoteIP = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv('REMOTE_ADDR') );
// Convert IP to long Address to make it store as a # in mysql
$RemoteIP = ip2long($RemoteIP);
$Current_time = time(); // Current Time
$Lockout_Expire = ($Current_time + 30); // Current Time + 30 Seconds
$query = "SELECT * FROM `IP_TBL` WHERE `IP_COL` ='{$RemoteIP}'"; // Set Up the Sql Query
$result = mysql_query($query); // Performs the Query
$moresql = mysql_fetch_array($result); // Creates an Array with your results in it called moresql
$numrows = mysql_num_rows($result); // The Number of Rows that match users IP Address
if ($numrows > 0) // If there is more then 0 rows found ie if the IP had a match in the table
{
$LockedOutTimeEnds = $moresql["Lockout_COL"]; // Gets the time listed in the table which is the time that the lockout will be over.
IF ($Current_time > $LockedOutTimeEnds)
{
// They Can Post because 30seconds is up
// In This Area they Have been given permission to post so you can put your origional Post function here.
// If they got here they have posted before, but it was longer then 30 seconds before now.
$sql = "INSERT INTO shitlist (firstname, lastname, city, state, reason) VALUES ('$first', '$last', '$city','$state','$reason')";
$result = mysql_query($sql);
echo "Submitted. Click <a href=index.php>here</a> to return to main page";
// When All is said and done update the lock out time for another 30seconds
$query = "UPDATE `IP_TBL` SET `Lockout_COL` = '{$Lockout_Expire}' WHERE `IP_COL` = '{$RemoteIP}' LIMIT 1 ";
mysql_query($query) or die(GENERAL_ERROR_Unable_to_Submit_Results_Please_Refresh_Browser);
} Else {
// No Post for you, you should wait a while.
Echo "You Fool, Why should I let you post 2x in 30 seconds. Go Away or I shall have to mock you some more<BR>";
}
} ELSE { // There was no match for the IP address.
// They Can Post Because There Ip Has Never Posted Before
// In This Area they Have been given permission to post so you can put your origional Post function here.
// If they got here they have never posted.
// When All is said and done Insert there IP to Lock them Out for 30 seconds
$query = "INSERT INTO `IP_TBL` ( `IP_COL` , `Lockout_COL`)";
$query.= "VALUES ('{$RemoteIP}', '{$Lockout_Expire}')";
mysql_query($query) or die(GENERAL_ERROR_Unable_to_Submit_Results_Please_Refresh_Browser);
$sql = "INSERT INTO shitlist (firstname, lastname, city, state, reason) VALUES ('$first', '$last', '$city','$state','$reason')";
$result = mysql_query($sql);
echo "Submitted. Click <a href=index.php>here</a> to return to main page";
}
?>