php自我电子邮件表单问题
我的php代码有问题。我使用jquery验证用户输入。当我点击提交按钮时,我收到了电子邮件,但我无法返回到其他页面,如“它已成功发送”。我是新来的,我不知道如何获得帮助,所以我将发布php页面,它发送到哪里,在哪里我不能这样做 此页面称为ajax.phpphp自我电子邮件表单问题,php,Php,我的php代码有问题。我使用jquery验证用户输入。当我点击提交按钮时,我收到了电子邮件,但我无法返回到其他页面,如“它已成功发送”。我是新来的,我不知道如何获得帮助,所以我将发布php页面,它发送到哪里,在哪里我不能这样做 此页面称为ajax.php 此页面是我提交的带有jquery验证“onblur”的表单 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
此页面是我提交的带有jquery验证“onblur”的表单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../style.css" rel="stylesheet" type="text/css" />
<script src="prototype.js" type="text/javascript"></script>
<script src="livevalidation.js" type="text/javascript"></script>
</head>
<body>
<div class="main">
<div class="footer_resize">
<div class="footer">
<div class="menu">
<ul>
<li><a href="../index.html">Home </a></li>
<li><a href="../services/services.html">Services</a></li>
<li><a href="contact.php" class="active">Contact Us</a></li>
</ul>
</div>
<div class="clr"></div>
</div>
</div>
<div class="clr"></div>
<div class="body">
<div class="body_resize">
<div class="left">
<h2>Contact for appointment</h2>
<p><a href="#"></a>
<strong>Address</strong>
<br />So Shiq Studio
<br />380 King Street North
<br />Waterloo ON
<br />Tel. 519.721.8060
<br /></p>
<p></p>
<p><strong>Hours of Operation</strong><br />
Tuesday: 10AM – 7PM <br />
Friday: 10AM – 8PM <br />
Saturday: 9AM – 3PM</p>
<p></p>
<p><strong>Private Appointments</strong><br />
Monday - Wednesday <br />
Colour Upon Consultation <br />
*Minimum 2 Services*</p>
<p><a href="#"></a><br />
</p>
<p>
<a href="#"><strong></strong></a><br />
</p>
</div>
<br /><br /><br />
<form id="my-form" style="padding-left:16.9em" >
<table class=shadow border="0" width="71%" style="background:#ececec; font:normal 12px Arial, Helvetica, sans-serif; color:#6b6b6b;" cellspacing="15">
<tr align="left"><td><strong>Full Name</strong></td><td><input type="text" size="50" id="name" name="name" style="font:normal 12px Arial, Helvetica, sans-serif; color:#6b6b6b;"></td></tr>
<tr align="left"><td><strong>Email Address</strong></td><td><input type="text" size="50" id="email" name="email" style="font:normal 12px Arial, Helvetica, sans-serif; color:#6b6b6b;"></td></tr>
<tr align="left"><td><strong>Phone Number</strong></td><td><input type="text" size="50" id="telephone" name="telephone" style="font:normal 12px Arial, Helvetica, sans-serif; color:#6b6b6b;"></td></tr>
<tr align="left"><td valign="top"><strong>Comments</strong></td><td><textarea id="message" name="message" rows="8" cols="80" style="font:normal 12px Arial, Helvetica, sans-serif; color:#6b6b6b;"></textarea></td></tr>
<tr align="left"><td> </td><td>
<input type="button" name:"clear" value="Send" onclick="sendRequest();" style="font:normal 12px Arial, Helvetica, sans-serif; color:#6b6b6b;font-weight:bold;"/></td></tr>
</table>
</form>
<script type="text/javascript">
var name = new LiveValidation( 'name' );
name.add( Validate.Presence );
var email = new LiveValidation( 'email' );
email.add( Validate.Presence );
email.add( Validate.Email );
var telephone = new LiveValidation( 'telephone' );
telephone.add( Validate.Presence );
telephone.add( Validate.Telephone );
var message = new LiveValidation( 'message' );
message.add( Validate.Presence );
function sendRequest(){
if(LiveValidation.massValidate( [ name, email, telephone, message ] )){
new Ajax.Request('ajax.php',
{
method:'post',
parameters: $('my-form').serialize(true),
onLoading: function(){
$('update_div').show();
$('update_div').innerHTML = "Sending...";
},
onSuccess: function(transport){
var response = transport.responseText || "No response text";
$('update_div').innerHTML = response;
},
onFailure: function(){
$('update_div').innerHTML = "Something went wrong...";
}
});
}
}
</script>
<br /><br /><br /><br />
<div class="clr"></div>
</div>
</div>
<div class="clr"></div>
<div class="clr"></div>
<div class="footer">
<div class="footer_resize">
<p class="leftt">
<a href="https://twitter.com/#!/atmosphair"><img src="../images/rss_1.gif" alt="picture" width="18" height="16" border="0" /></a>
<a href="https://www.facebook.com/pages/Atmosphair-Salon/132172773469260"><img src="../images/rss_2.gif" alt="picture" width="18" height="16" border="0" /></a>
</p><p class="right"> <a href="#">© Copyright COSMO STEFAN All Rights Reserved </a></p>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
</div>
</body>
</html>
联系我们
预约联系人
地址
苏诗工作室
国王街北380号
滑铁卢
电话:519.721.8060
运行时间
星期二:上午10时至下午7时
星期五:上午10时至晚上8时
星期六:上午9时至下午3时
私人约会
周一至周三
咨询后的颜色
*最少2项服务*
全名
电子邮件地址
电话号码
评论
var name=新的LiveValidation('name');
name.add(Validate.Presence);
var email=新的LiveValidation('email');
email.add(Validate.Presence);
email.add(Validate.email);
var电话=新的现场验证(“电话”);
电话。添加(验证。存在);
电话。添加(验证。电话);
var message=newlivevalidation('message');
message.add(Validate.Presence);
函数sendRequest(){
if(LiveValidation.massValidate([姓名、电子邮件、电话、消息]){
新的Ajax.Request('Ajax.php',
{
方法:'post',
参数:$('my-form')。序列化(true),
onload:function(){
$('update_div').show();
$('update_div')。innerHTML=“发送…”;
},
onSuccess:功能(传输){
var response=transport.responseText | |“无响应文本”;
$('update_div')。innerHTML=响应;
},
onFailure:function(){
$('update_div').innerHTML=“出了问题…”;
}
});
}
}
我尝试了下面两位的建议,但我无法让它正常工作。我知道代码很混乱,我对这一点很陌生,只是想弄清楚我做错了什么。。非常感谢你的帮助。更新
使用标题()
要使用PHP重定向页面,请使用函数。此函数用于将HTTP头发送回客户端。如果发送带有值的HTTP位置头,客户端或多或少会将其解释为“转到值中指定的页面”
要使用header函数重定向,请执行以下操作:
<?php
header('Location: http://www.yoursite.com/the/page/you/want/to/go/to.php?success=1');
exit();
?>
您可以通过检查$\u GET['success']
是否设置为等于1来告知您的呼叫页面您的电子邮件已发送,然后输出您的邮件
<?php
if(isset($_GET['success']) && $_GET['success'] == 1)
echo( 'Email Successfully Sent!<br />' );
?>
有更复杂的方法可以做到这一点,但我相信这可能是最容易和最快的实现。在调用
header()
函数之前,请确保不要输出任何内容。我已经整理了下面的代码。应该行得通
<?
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$telephone = stripslashes($telephone);
$message = stripslashes($message);
if(mail("mememe@hotmail.com","Email from". $name.$message))
{
echo "Email Successfully Sent!<br /><br />Name:". $name."<br />Email:". $email."<br />telephone:". $telephone."<br />Message:". $message;
}
?>
如果你想重定向到成功页面,这是代码
<?
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$telephone = stripslashes($telephone);
$message = stripslashes($message);
if(mail("mememe@hotmail.com","Email from". $name.$message))
{
//echo "Email Successfully Sent!<br /><br />Name:". $name."<br />Email:". $email."<br />telephone:". $telephone."<br />Message:". $message;
header("location:http://www.yourdomain.com/success.html");
}
?>
谢谢您的建议。我对这一点很陌生,所以我感到困惑和挣扎。“获得['success']”部分我有点困惑。假设我想返回重定向回电子邮件表单页。。我应该把这个代码放在哪里?我已经更新了我的答案,如果你有任何进一步的问题,请告诉我。
<?
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$telephone = stripslashes($telephone);
$message = stripslashes($message);
if(mail("mememe@hotmail.com","Email from". $name.$message))
{
echo "Email Successfully Sent!<br /><br />Name:". $name."<br />Email:". $email."<br />telephone:". $telephone."<br />Message:". $message;
}
?>
<?
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$telephone = stripslashes($telephone);
$message = stripslashes($message);
if(mail("mememe@hotmail.com","Email from". $name.$message))
{
//echo "Email Successfully Sent!<br /><br />Name:". $name."<br />Email:". $email."<br />telephone:". $telephone."<br />Message:". $message;
header("location:http://www.yourdomain.com/success.html");
}
?>