我创建了一个表单来发送联系人数据。我想客户端发送表单并保留在主页面(index.html)。这里是php代码:
PHP:
if(mail($to, $subject, $message, $headers))
echo"<script>alert('message send succesfully')</script>";
else
echo"<script>alert('message not send')</script>";
答案 0 :(得分:0)
更改为index.php
添加此
// 'to' should be the name of your input field
if (!empty($_POST['to'])) {
if (mail($to, $subject, $message, $headers)) {
echo"<script>alert('message send succesfully');</script>";
}
else {
echo"<script>alert('message not send');</script>";
}
}