发送表格并留在页面上

时间:2014-03-28 08:09:43

标签: php jquery forms

我创建了一个表单来发送联系人数据。我想客户端发送表单并保留在主页面(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>";

1 个答案:

答案 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>";
    }
}