Ho il seguente form
<?php
// Replace this with your own email address
$siteOwnersEmail = 'la@gmail.com';
if($_POST) {
$name = trim(stripslashes($_POST['contactName']));
$email = trim(stripslashes($_POST['contactEmail']));
$subject = trim(stripslashes($_POST['contactSubject']));
$contact_message = trim(stripslashes($_POST['contactMessage']));
// Check Name
if (strlen($name) < 2) {
$error['name'] = "Inserire il nome.";
}
// Check Email
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Inserire un indirizzo mail valido.";
}
// Check Message
if (strlen($contact_message) < 15) {
$error['message'] = "Inserisci il tuo messaggio. Dovrebbe avere almeno 15 caratteri..";
}
// Subject
if ($subject == '') { $subject = "Contact Form Submission"; }
// Set Message
[u]$message .= "Email from: " . $name . "<br />";[/u]
$message .= "Email address: " . $email . "<br />";
$message .= "Message: <br />";
$message .= $contact_message;
$message .= "<br /> ----- <br /> This email was sent from your site's contact form. <br />";
// Set From: header
$from = $name . " <" . $email . ">";
// Email Headers
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
[u]if (!$error) {[/u]
ini_set("sendmail_from", $siteOwnersEmail); // for windows server
$mail = mail($siteOwnersEmail, $subject, $message, $headers);
if ($mail) { echo "OK"; }
else { echo "Something went wrong. Please try again."; }
} # end if - no validation error
else {
$response = (isset($error['name'])) ? $error['name'] . "<br /> \n" : null;
$response .= (isset($error['email'])) ? $error['email'] . "<br /> \n" : null;
$response .= (isset($error['message'])) ? $error['message'] . "<br />" : null;
echo $response;
} # end if - there was a validation error
}
?>
come risolvo i
seguenti errori :
ho sottolineato le righe dove ci sta l'errore
Notice: Undefined variable: message inC:\xampp\htdocs\co\inc\sendEmail.php on line 31
Notice: Undefined variable: error inC:\xampp\htdocs\co\inc\sendEmail.php on line 47
OK