我有一个Html网站。在每个页面都有发送邮件的表单。表单操作在另一个页面上完成,即process.php页面。我希望在发送邮件后从php页面重定向到html页面。 这是我的HTML代码
<form name="mail" id="mail" method="post" action="process.php" onSubmit="return valid_form();">
<div class="form_bg11">
<div class="free_call_back">Free Callback Request</div>
<input name="txtname" id="txtname" type="text" class="free_cal_field" value="Your Name" onClick="(this.value='')" >
<input name="txtphone" id="txtphone" type="text" class="free_cal_field" value="Your Phone Number" onClick="(this.value='')">
<input type="submit" name="Submit" style="background-image: url('images/submit.png'); border: 0px none; height: 19px; margin-left: 85px; width: 56px; margin-top:5px;" value=" ">
</div>
</form>
这是我的process.php页面
<?php
if(isset($_POST['Submit']))
{
$name = $_POST['txtname'];
$phone = $_POST['txtphone'];
$to = "mariyadavis90@gmail.com";
$subject = "New Request Come !";
$message = '<div style="background-color: #EEEEEE;border-bottom: 1px solid #DCDCDC;padding: 10px 0 20px;width: 400px;">
<div style="width:400px;">
<div style="width:400px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">
<div style="width:300px; text-align:center;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;">
Now you got a new request from :
</div>
</div> <!--end of div_form_main-->
<div style="width:400px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">
<div style="float:left;width:150px;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;"> Name:</div>
<div style="float:left;width:auto;color:#000000;font-size:12px;font-weight:bold;">'.$name.'</div>
</div> <!--end of div_form_main-->
<!--end of div_form_main-->
<div style="width:400px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">
<div style="float:left;width:150px;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;"> Phone Number:</div>
<div style="float:left;width:auto;color:#000000;font-size:12px;font-weight:bold;">'.$phone.'</div></div> <!--end of div_form_main-->
</div> <!--end of div_password_main-->';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .="Content-Transfer-Encoding: 8bit";
if(!mail($to, $subject, $message, $headers))
{
$msg = "Sending mail is failed !";
}
else
{
$msg = "Mail send Successfully !";
}
print "<script type=\"text/javascript\">";
print "alert('".$msg."')";
print "</script>";
}
?>
我该怎么做?
答案 0 :(得分:0)
我对你的措辞感到有点困惑。为什么不能只使用PHP header()
函数?
header('Location: http://www.example.com/');
答案 1 :(得分:0)
快速写下
if(!mail($to, $subject, $message, $headers))
{
$msg = "Sending mail is failed !";
}
else
{
$msg = "Mail send Successfully !";
print "<script type=\"text/javascript\">";
print "window.location.href= 'www.example.com' ";
print "</script>";
}
print "<script type=\"text/javascript\">";
print "alert('".$msg."')";
print "</script>";
答案 2 :(得分:0)
你可以修改你的procss.php(在你的javascript块中)
print "<script type=\"text/javascript\">";
print "alert('".$msg."')";
print "window.location.href='http://www.yourdomain/yourhtmlpage.html'";
print "</script>";