Flash AS3 navigatorToURL() 和 php mail()
我正在尝试使用navigateToURL() 和PHP mail() 创建一个简单的消息表单。但我对这种在 php 页面中重定向的方法有疑问。我需要它不重定向页面,但仍将其发送到电子邮件。
这就是我所做的。
AS3
if (e.type == "click")
{
navigateToURL(new URLRequest("http://somedomain.com/sendme.php?" + "name=" + e.currentTarget.parent.na_txt.text + "&email=" + e.currentTarget.parent.ma_txt.text + "&contact=" + e.currentTarget.parent.co_txt.text + "&message=" + e.currentTarget.parent.me_txt.text + "&sex=" + e.currentTarget.parent.sex), "_self");
}
PHP
<?php
$to = "[email protected]";
$subject = "Subject";
$name = $_GET['name'];
$sex = $_GET['sex'];
$email = $_GET['email'];
$contact = $_GET['contact'];
$message = $_GET['message'];
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.email."\r\n" .
'X-Mailer: PHP/' . phpversion();
$body = "From: $name \r\nGender: $sex \r\nE-Mail: $email \r\nContact No.: $contact \r\n\r\nMessage:\n$message";
echo "Thank You $name, Your Feedback and Enquiry has been submitted to <a href='mailto:$to'>$to</a>!";
mail($to, $subject, $body, $headers);
?>
I'm trying to create a simple message form using navigateToURL() and PHP mail(). But I have a problem with this approach it redirects in the php page. I need it not to redirect the page but still send it to the email.
here's what I did.
AS3
if (e.type == "click")
{
navigateToURL(new URLRequest("http://somedomain.com/sendme.php?" + "name=" + e.currentTarget.parent.na_txt.text + "&email=" + e.currentTarget.parent.ma_txt.text + "&contact=" + e.currentTarget.parent.co_txt.text + "&message=" + e.currentTarget.parent.me_txt.text + "&sex=" + e.currentTarget.parent.sex), "_self");
}
PHP
<?php
$to = "[email protected]";
$subject = "Subject";
$name = $_GET['name'];
$sex = $_GET['sex'];
$email = $_GET['email'];
$contact = $_GET['contact'];
$message = $_GET['message'];
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.email."\r\n" .
'X-Mailer: PHP/' . phpversion();
$body = "From: $name \r\nGender: $sex \r\nE-Mail: $email \r\nContact No.: $contact \r\n\r\nMessage:\n$message";
echo "Thank You $name, Your Feedback and Enquiry has been submitted to <a href='mailto:$to'>$to</a>!";
mail($to, $subject, $body, $headers);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您真正想要的是创建一个 URLLoader 对象来发送变量。
这将在不重新加载页面或打开新窗口的情况下运行,从而允许您维护应用程序的状态。您从 PHP 回显的文本将在加载完成处理函数中可用,供您以您选择的方式向用户显示。
I think what you really want is to create a URLLoader object to send your variables though.
This will run without reloading the page or opening a new window, allowing you to maintain the state of your application. The text that you echo from PHP will be available in the load complete handler function for you to display to the user however you choose.