提交表单并加载新页面

时间:2014-10-14 10:44:38

标签: php

我正在尝试使用JQM页面通过表单发送电子邮件,然后重定向到新页面。我的邮件部分工作正常,但重定向不是那么多!表单提交并发送邮件后,页面基本上只刷新而不是加载新页面。我使用代码header('Location:myredirectpage');尝试了很多不同的东西,但没有任何作用。

以下php代码位于我页面底部的结束HTML标记下方。

<?php

if(isset($_POST['mr'])) { 

    $to = "myemailaddress";
    $subject = "Subject";
    $content = ""
                    ."Survey Details"."\n\n"
                    ."How did you hear about us: ".$_POST['mr']."\n";

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: <myemailaddress>\r\n";

    mail($to, $subject, $content, $headers);

    $sendit= @mail($to, $subject, $content, $headers);

    if($sendit){

      header('Location:myredirectpage');

    }else{ echo "Email failed to send";}
}

?>

3 个答案:

答案 0 :(得分:1)

要在发送页面后重定向页面,您需要采用以下格式的内容:

header('Location: index.php');

将index.php更改为您想要获取的FILENAME。

这可以是完整的网址,例如http://google.com

答案 1 :(得分:0)

您要发送两次邮件:mail(...)然后@mail(...)。 将@mail(...)@一起使用也被视为不良做法。

答案 2 :(得分:-1)

而不是header('Location:myredirectpage');使用

echo '<script>window.location = 'yourpage'</script>'

试试这个

相关问题