除了 1(一个)变量之外的所有东西似乎都在我的邮件表单上工作。在我的 HTML 页面上,我有一个带有选择框、一些文本输入和消息的文本区域的表单。正在检索除消息变量之外的所有内容。
我对这些基于 PHP 的邮件表单从来没有这么好过。我通常使用 HTML mailto 表单,但它们不安全且非常初级。
我会很感激你的帮助。谢谢!
HTML
<form method="post" action="php/contact.php">
<label for="senderName">name:</label> <input name="senderName" type="text" /><br />
<label for="senderEmail">email:</label> <input name="senderEmail" type="text" /><br />
<label for="senderRegarding">subject:</label>
<select name="senderRegarding">
<option value="start a project">Wish to start a project</option>
<option value="request resume password">Request resumé password</option>
<option value="other">Other</option>
</select><br />
<label for="senderMessage">message:</label> <textarea name="senderMessage"></textarea><br />
<input type="submit" name="submit" /> <input type="reset" />
</form>
PHP
<?php
if (isset($_POST['submit'])){
$name = $_POST['senderName'];
$email = $_POST['senderEmail'];
$regarding = $_POST['senderRegarding'];
$message = $_POST['message'];
$subject = "Contact Form";
$message =
"Name: " . $name . "\r\n" .
"Email: " . $email . "\r\n" .
"Subject: ". $regarding . "\r\n" .
"Message: " . $senderMessage;
$headers =
"From: " . $name . "\r\n" .
"Reply-To: " . $email . "\r\n" .
"MIME-Version: 1.0\n" .
"Content-type: text/plain; charset=iso-8859-1\n";
$to = "email@address";
};
mail($to, $subject, $message, $headers);
header("Location:../index.htm");
?>