I am using MySQL on a non-local server.
My table "hai1" is not accepting input. Here is my table DESC:
Code:
id MEDIUMINT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY
date DATE NOT NULL
pagefrom ENUM('Need','Donate','Copay Need','Copay Donation')
contact VARCHAR(50)
company VARCHAR(255)
address VARCHAR(255)
telephone VARCHAR(20)
email VARCHAR(255) NOT NULL
needdonortype ENUM('Assistive Devices','Medical Devices','Emergency Cell Phone','All Other')
needdonorspecs VARCHAR(255) NOT NULL
copayamtreqd DOUBLE NOT NULL
copaymedcondtns VARCHAR(255) NOT NULL
copaydonationamt DOUBLE
copaydonationspecs VARCHAR(255) NOT NULL
approved ENUM('Y','N') NOT NULL DEFAULT 'N'
My include has the db connect (which has worked before on this page). On this particular page, I check for blanks from the previous page, then I want it to write to the db, post the db-inserted info onto a new php page, and email the administrator with the information so they can process it. The company, copayamtreqd, copaymedcondtns, copaydonationamt, and copaydonationspecs aren't asked for on this page, so I added "NULL"s to the INSERT INTO command.
Code:
<html>
<head>
<title>Need Help?</title>
</head>
<body>
<?php
if ($email=="") {
echo "<p>Your email address is required so you can be contacted. Click the Back button to fill in this blank.</p>";
exit;
}
if ($needdonorspecs=="") {
echo "<p>Specifics are required so someone can meet your need. Click the Back button to fill in this blank.</p>";
exit;
}
include "common.inc";
error_reporting(0);
$link_id = db_connect();
if(!$link_id) die(sql_error());
else {
$mail_to = "me@mydomain.com";
$mail_subject = "Need Help Form (WS)";
$mail_body = "Contact name: ";
$mail_body .= $contact;
$mail_body .= "\n";
$mail_body .= "Address: ";
$mail_body .= $address;
$mail_body .= "\n";
$mail_body .= "Telephone: ";
$mail_body .= $telephone;
$mail_body .= "\n";
$mail_body .= "Email: ";
$mail_body .= $email;
$mail_body .= "\n";
$mail_body .= "I need: ";
$mail_body .= $needdonortype;
$mail_body .= "\n";
$mail_body .= "Please describe what exactly you need and why: ";
$mail_body .= $needdonorspecs;
$mail_body .= "\n";
$mail_from = "From: ".$email."\nReply-To: ".$mail_from;
if(mail($mail_to, $mail_subject, $mail_body, $mail_from)) {
$result = mysql_query("INSERT INTO hai1 VALUES(NULL, CURDATE(), 'Need', '$contact', NULL, '$address', '$telephone', '$email', '$needdonortype', '$needdonorspecs', NULL, NULL, NULL, NULL, 'N')",$link_id);
echo "<h1>Thank you!</h1>";
echo "<p>The following information was entered into our database:</p>";
echo "<p>Contact name: ";
echo $contact;
echo "<br>";
echo "Address: ";
echo $address;
echo "<br>";
echo "Telephone: ";
echo $telephone;
echo "<br>";
echo "Email: ";
echo $email;
echo "<br>";
echo "I need: ";
echo $needdonortype;
echo "<br>";
echo "Please describe what exactly you need and why: ";
echo $needdonorspecs;
echo "</p>";
echo "<p>::::::: End Data Transmission :::::::</p>";
echo "<p><b>Remember:</b> Your submission has been sent to our administrator for posting approval. It will be available for viewing for approximately 30 days once it is posted. You will be contacted around that time to see if your request needs to be extended.</p>";
}
else echo "<p>Operation failed. Please contact us via <a href='mailto:me@mydomain.com?subject=Need_Help_Form-em'>email</a> instead. We are sorry for the inconvenience.</p>";
}
mysql_close($link_id);
?>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
It produces the php page and emails the administrator, but it won't insert the info into the db.
I don't know where I've gone wrong and would appreciate another pair or two of eyes to help me troubleshoot my coding.
Thanks!