Im making this thing on my site. A contact form. I want it so that when they press submit it logs the ip and stores it into a mysql db. I want it on submit though, just not any ip logged, because I want it logged so that if someone does something stupid or so I can ban them.

I found this script on the web for the ip logging

Code:
<head>
<meta  http-equiv="Content-Language" content="en-us">
</head>

<?

$ip  = $_SERVER['REMOTE_ADDR'];

$date = date('l jS \of F Y h:i:s A');

?>

<?php

include('config.php');

$sql="INSERT  INTO request (ip, date)
VALUES
('$ip','$date')";

if  (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
   }
echo "";

mysql_close($con)
?>
However that is just to log the ips. I need it to log them when they press submit.