2013-08-27 6 views
0

프로젝트 작업 중입니다.양식 데이터 값을 PHP에 제출 한 후 성공적인 메시지를 위해 PrettyPhoto Lightbox를 실행하십시오.

사용자 피드백을 수집하는 양식 웹 페이지가 있습니다. 사용자가 제출 버튼을 클릭하면 사용자가 입력 한 값 데이터가 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> 

send_email.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._%-][email protected][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 = '[email protected]'; 
// 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("[email protected]", $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 
//} 
?> 
+1

로하는 것은 나는 그것이 링크가 이에 내 Google지도보기로 큰 맵 웹 페이지를 통합 한 – allen213

+0

을 치지 시작에 대한 몇 가지 자바 스크립트를 추가합니다. 이 경우 양식 제출입니다. 나는 어디서부터 시작해야할지 모르겠습니다. $ ("area [rel^= 'prettyPhoto']"). prettyPhoto(); $ ("a [rel^= 'prettyPhoto']"). prettyPhoto(); – crank

+0

질문에 더 많은 코드 게시 – allen213

답변

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> 
+0

으로 업데이트 안녕하세요 hendr1x, 오늘 밤 시도해 보겠습니다. 그건 그렇고, 하나의 질문, 지금 내 유효성 검사는 PHP 파일에 있습니다. 그러나 jQuery 유효성 검사로 이동하고 싶습니다. PrettyPhoto를 방해합니까? 내가 생각하기에, 그렇게되지는 않을 것이다. – crank

+0

안녕하세요 hendr1x, 작동하지 않습니다. 양식을 제출하면 send_email.php로 보내지 만 라이트 박스는 보내지 않습니다. 메시지가있는 일반 웹 페이지 일뿐입니다. – crank