0

我正在做一个项目。

我有表单网页来收集用户反馈。用户单击提交按钮后,用户输入的值数据将传递给 send_email.php 以将信息通过电子邮件发送给客户端和用户,以便收到新的反馈。如果成功,我会打印一条消息,它已成功发送。

我有一个关于打印成功消息的问题。我想让消息显示在 PrettyPhoto Lightbox 中。我可以知道我该怎么做吗?

根据我的研究,更接近的脚本是 $.prettyPhoto.open

但是,我在处理它时遇到了问题,因为我有后操作代码。send_email.php 包含发送电子邮件和显示成功消息的代码。我可以知道如何调整我的代码,以便成功消息或错误消息可以显示在 PrettyPhoto Lightbox 中吗?

非常感谢。

<form id="enquiry_form" method="post" action="send_email.php?iframe=true&amp;width=600&amp;height=300">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="115"><label>Name: </label></td>
                    <td><input class="input_field" type="text" name="name"></td>
                </tr>
                <tr>
                    <td height="10"></td>
                    <td height="10"></td>
                </tr>
                <tr>
                    <td><label>Contact No: </label></td>
                    <td><input class="input_field" type="text" name="contactnum"><br/></td>
                </tr>
                <tr>
                    <td height="10"></td>
                    <td height="10"></td>
                </tr>
                <tr>
                    <td><label>Email Address: </label></td>
                    <td><input class="input_field" type="text" name="emailaddr"><br/></td>
                </tr>
                <tr>
                    <td height="10"></td>
                    <td height="10"></td>
                </tr>
                <tr>
                    <td><label>Message: </label></td>
                    <td><textarea name="message" id="message" rows=7 class="text_field2">Enter your message here</textarea></td>
                </tr>
                <tr>
                    <td height="30"></td>
                    <td height="30"></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input id="submit_form" type="image" src="images/buttons/btn_submit.jpg" name="Submit"></td>
                </tr>
            </table>
            </form>

发送电子邮件.php:

<?php



function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you have submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
}

// validation expected data exists
if(!isset($_POST['name']) ||
    !isset($_POST['contactnum']) ||
    !isset($_POST['emailaddr']) ||
    !isset($_POST['message'])) {
    died('We are sorry, but there appears to be a problem with the form you have submitted.');      
}

$name = $_POST['name']; // required
$contactnum = $_POST['contactnum']; // required
$email = $_POST['emailaddr']; // required
$msg = $_POST['message']; // required

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';


if(!preg_match($email_exp,$email)) {
$error_message .= 'The email address you entered does not appear to be valid.<br />';


}
$string_exp = "/^[A-Za-z .'-]+$/";


if(!preg_match($string_exp,$name)) {
$error_message .= 'The name you entered does not appear to be valid.<br />';
  }


if(strlen($msg) < 2) {
$error_message .= 'The comments you entered do not appear to be valid.<br />';


}

if(strlen($error_message) > 0) {
died($error_message);


}
$email_message = "Form details below.\n\n";

function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}

$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Contact Number: ".clean_string($contactnum)."\n";
$email_message .= "Email Address: ".clean_string($email)."\n";
$email_message .= "Message: ".clean_string($msg)."\n";

$email_from = 'myemail@email.com';
// create email headers

$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();



$subject_title = "New Enquiry from ". $name;
$email_body_message = "You have received a new enquiry from " . $name . ", " . $email_message;


mail("myemail@email.com", $subject_title, $email_body_message, $headers);
//send to user
mail($email, "Feedback Received Confirmation", "Dear " . $name . ",\nThank you for contacting us. This is an automated response confirming the receipt of your feedback. We will get back to you as soon as possible.", $headers);
?>


<!-- include your own success html here -->


Thank you for contacting us. We will be in touch with you very soon.
    <?php
//}
?>
4

1 回答 1

0

所以我假设除了让弹出窗口正确显示之外,您不希望任何评论/帮助......将“感谢您与我们联系......”文本替换为

<html><!-- you should probably just include you head file here-->
<body>
<div id="prettyPhoto">Thank you for contacting us. We will be in touch with you very soon.</div>
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("#prettyPhoto").prettyPhoto();
  });
</script>
</body>
</html>
于 2013-08-27T15:19:29.937 回答