How do I add the $ip address form field to this database code?
$form_vars = array('one','two','three');
$ip = getenv("REMOTE_ADDR");
$query = "INSERT INTO recommended SET ";
for ($i = 0; $i < count($form_vars); $i++) {
$query .= $form_vars[$i].'="'.AddSlashes($_REQUEST[$form_vars[$i]]).'",';
}
$query .= 'DateTime="'.date('y/m/d g:i a').'"';
$result = mysql_query($query) or die("Error in query: $sql. ".mysql_error());
The get $IP line is there but I can't get it to work in the Insert.
I've just reused this code over time but it seems there are 3 assignments to $query. Is there a simpler way to write this since it's used all the time?
Thanks!