我目前正在制作一个联系表单,允许用户提交将邮件重新路由到联系电子邮件的消息(一般基本的php电子邮件处理程序。我目前正在使用Brackets实时预览查看和编辑此内容而不是确定这与我遇到的问题有什么关系
HTML
<form action="mail_handler.php" method="post">
<div class="w3-row-padding" style="margin:0 -16px 8px -16px">
<div class="w3-half">
<input class="w3-input w3-border" type="text" placeholder="Name" required name="name">
</div>
<div class="w3-half">
<input class="w3-input w3-border" type="email" placeholder="Email" required name="email">
</div>
</div>
<input class="w3-input w3-border" type="text" placeholder="Message" required name="message">
<button class="w3-button w3-black w3-right w3-section" type="submit">
<i class="fa fa-paper-plane"></i> SEND MESSAGE
</button>
</form>
PHP
<?php
if(isset($_POST['submit'])){
$to = "email@email.com";
$from = $_POST['email'];
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
header('Location: email_confirm.html');
exit();
}
&GT;
同样,我不确定这只是括号或代码错误的问题。我非常感谢一些反馈。谢谢!
编辑:这不是变量的问题,请不要将缺失变量标记为重复。这个问题已得到解决,而不是解决方案。
答案 0 :(得分:0)
在HTML
中更改此内容<button class="w3-button w3-black w3-right w3-section" type="submit">
使用
<input class="w3-button w3-black w3-right w3-section" type="submit" value="Submit" name="submit">