在我的网站上有一个查询表格,在输入电子邮件后无法发送电子邮件并点击提交获取“邮件无法发送”。它正在重定向到另一个并显示该消息。需要在该网站上显示该消息同一页。这是代码:
的index.php
<form action="contact.php" method="post" enctype="multipart/form-data">
<input type="email" size="30" placeholder=" Enter your Email and Get Notified..." name="email" id="email">
<a href="#"><button type="submit" class="btn span btn-4 btn-4a icon-arrow-right"><span></span></button></a>
<div id="response"></div>
</form>
contact.php:
<?php
$connection = mysql_connect("localhost", "mk_group", "12345") or die(mysql_error());
$db = mysql_select_db("group", $connection);
$email = $_POST['email'] ;
$sql2 = mysql_query("insert into contact_us(email) values ('$email')");
if ($sql2)
{
$to = "xxx@gmail.com,yyy@gmail.com";
$subject = 'the subject';
$message = 'hello';
$retval = mail ($to,$subject,$message);
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
答案 0 :(得分:1)
函数mail(string $to , string $subject , string $message)
需要3个参数,而你只设置一个