i apologize for not giving more information into the issue....
I updated the file to make sure the variables were all named properly. I even went and renamed the fields in the HTML and just kept it consistent with the names.
HEre is where I am at:
<?php
if(isset($_POST['submit'])) {
$to = "example@example.com";
$subject = "Promotional Download";
$name_field = $_POST['name_field'];
$email_field = $_POST['email_field'];
$date_book_was_bought = $_POST['date_book_was_bought'];
$headers = "FROM: $email_field";
$ip = gethostbyname($_SERVER['REMOTE_ADDR']);
mysql_select_db($database, $connection);
$insert_query = sprintf("INSERT INTO contacts (name_field, email_field, date_book_was_bought, date, ip) VALUES (%s, %s, %s, %s, NOW(), %s)",
sanitize($name_field, "text"),
sanitize($email_field, "text"),
sanitize($date_book_was_bought, "text"),
sanitize($ip, "text"));
$result = mysql_query($insert_query, $connection) or die(mysql_error());
if($result)
{
//headers and subject
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$body = "Name: $name_field\nE-Mail: $email_field \nDate Book was Purchased: $date_book_was_bought";
echo "Data has been submitted to $to!";
mail($to, $subject, $body, $headers);
} else {
echo "blarg!";
}
function sanitize($value, $type)
{
$value = (!get_magic_quotes_gpc()) ? addslashes($value) : $value;
switch ($type) {
case "text":
$value = ($value != "") ? "'" . $value . "'" : "NULL";
break;
case "long":
case "int":
$value = ($value != "") ? intval($value) : "NULL";
break;
case "double":
$value = ($value != "") ? "'" . doubleval($value) . "'" : "NULL";
break;
case "date":
$value = ($value != "") ? "'" . $value . "'" : "NULL";
break;
}
return $value;
}
}
?>
and IM getting this when I execute:
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/profits/public_html/mailer/mailer3.php on line 13
Fatal error: Call to undefined function sanitize() in /home/profits/public_html/mailer/mailer3.php on line 16