PHPでフォームを使用してメールを送信しようとしています。
私のphpコード:
<?php
$name = trim(strip_tags(stripslashes($_POST['name'])));
$email = trim(strip_tags(stripslashes($_POST['email'])));
$subject = trim(strip_tags(stripslashes($_POST['subject'])));
$message = trim(strip_tags(stripslashes($_POST['message'])));
$successful = "Message was sent";
$failure = "Message was not sent";
$header = "From: $email\r\n";
$validEmail = filter_var($email, FILTER_VALIDATE_EMAIL);
if ($name <> "" && $email <> "" && $subject <> "" && $message <> "") {
if ($validEmail) {
mail ("myemail@em.com", $subject, $message, $header);
header("Location: emailsent.php?message=$successful");
}
else {
header("Location: emailnotsent.php?message=$failure");
}
}
?>
私のHTML:
<form method="post" name="contact" action="sendMail.php">
<label for="author">Name:</label> <input type="text" id="author" name="name" class="required input_field" />
<div class="cleaner h10"></div>
<label for="email">Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" />
<div class="cleaner h10"></div>
<label for="subject">Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject"/>
<div class="cleaner h10"></div>
<label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" name="message" class="required"></textarea>
<div class="cleaner h10"></div>
<input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_r" />
<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_l" />
</form>
フォームを送信すると、次のエラーが表示されます。
致命的なエラー: 未定義の関数への呼び出し: 13 行目の /home/web/i/interfaithmedical.com/htdocs/PagesByZ/sendMail.php の filter_var()