Error sending your message please try again latter
Dear All, kindly help me out on this urgently. I actually wrote an sql script for my contact us page and got back this sql errors each time i try to fill in the form and click on submit button.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-form ( name, email, telephone, subject, enquiry ) WHERE ('Johnson', 'dammyadey2' at line 1
}
Below is the code for easy referencing:
if(isset($_POST['submit'])) {
$errors = array();
$required_fields = array('name', 'email', 'telephone', 'subject', 'enquiry');
foreach($required_fields as $fieldname){
if(!isset($_POST[$fieldname]) || empty($_POST[$fieldname])){
$errors[] = $fieldname;
}
}
$fields_with_lengths = array('name' => 30);
foreach($fields_with_lengths as $fieldname => $maxlength) {
if (strlen(trim(magic_quote($_POST[$fieldname]))) > $maxlength){
$errors[] = $fieldname;}
}
if (empty($errors)){
//perform the update
$id = magic_quote($_GET['id']);
$name = magic_quote($_POST['name']);
$email = magic_quote($_POST['email']);
$telephone = magic_quote($_POST['telephone']);
$subject = magic_quote($_POST['subject']);
$enquiry = magic_quote($_POST['enquiry']);
$query = "INSERT INTO contact-form (
name, email, telephone, subject, enquiry
) WHERE ('$name', '$email', '$telephone', '$subject', '$enquiry' )";
$result = mysql_query($query, $db_connect);
if ($result) {
//redirecting to login page.
mail("info@dynamicanchor.com",$name,$email, $telephone,$subject,$enquiry,"From: $from\n");
echo "Thank you for Contacting Dynamic Management Services (DMS). Your request will be attended to shortly!";
exit;
}else {
echo "<p> Error sending your message please try again latter. SERVER BUSY </p>";
}
Kindly help me out as i needed to submit this to my superior in less than 8 hours now...
Thank you.
Regards,
Dammyadey25