PHP电子邮件表单未发送。有人可以看一下我的代码,看看他们是否注意到了什么。
下面是我的index.html中的html表单
<form class= "contact-form" action="php/send.php" method="post">
<input type="text" name="subject" placeholder="Subject" required />
<input type="email" name="email" type= "email" placeholder="Email" required />
<textarea name="message" placeholder="Message" required></textarea>
<input type="submit" name "submit" value"Send" class="sub-btn">
</form>
下面是我要发送的php代码
<?php
if(isset($_POST['submit'])){
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = 'myemail@gmail.com';
if(mail($to,$subject,$message)){
echo "Sent Successfully! We will contact you shortly!";
}
else
{
echo "Something went wrong!";
}
}
?>
答案 0 :(得分:0)
我在您的表单HTML代码中看到您的名字和最后输入值中的值之间没有=号。 HTML表单应为:
<form class= "contact-form" action="php/send.php" method="post">
<input type="text" name="subject" placeholder="Subject" required />
<input type="email" name="email" type= "email" placeholder="Email" required />
<textarea name="message" placeholder="Message" required></textarea>
<input type="submit" name="submit" value="Send" class="sub-btn">
</form>