2013-05-04 1 views
0

마침내 내 양식 정보가 내 이메일로 전송되었지만 양식 웹 페이지에 문제가 있습니다. 제출 버튼을 누르면 브라우저가 페이지를 새로 고치지 않고 내 php.file로 이동하여 페이지를 표시합니다. 나는 (자바 스크립트를 사용하지 않고) 양식 웹 페이지로 페이지를 다시 보냅니다. 여기 정보를 제출 한 후 양식을 리디렉션하는 방법은 무엇입니까?

는 지금까지 PHP 파일을 포함하여 내 코드 :

<form method="post" action="PHP_Email_Form.php"> 
          <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
          font-weight:bold"><label>First Name: 
           <input type="text" name="First Name" size="30" maxlength="30" 
           style="margin-left:27px" /> 
          </label></p> 
          <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
          font-weight:bold"><label>Last Name: 
           <input type="text" name="Last Name" size="30" maxlength="30" 
           style="margin-left:27px" /> 
          </label></p> 
          <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
          font-weight:bold"><label>Phone Number: 
           <input type="text" name="Phone Number" size="30" maxlength="10" 
           style="margin-left:5px" /> 
          </label></p> 
          <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
          font-weight:bold"><label>Email: 
           <input type="text" name="Email" size="30" maxlength="30" 
           style="margin-left:59px" /> 
          </label></p> 
          <p style="margin-top:19px; margin-left:244px;"> 
           <input type="submit" value="submit" /> 
          </p> 

         </form> 

PHP 문서 :

<?php 
... 
... 
mail($to, $subject, $message); 

header("Location: successmessage.php"); // Redirect browser 

/* Make sure that code below does not get executed when we redirect. */ 
exit; 

: 성공적으로 이메일을 보낸 후

<?php 
$to = '[email protected]'; 
$subject = 'test email form'; 
$message= ''; 
foreach ($_POST as $key => $value) 
{ 
    $message .= $key . ': ' . $value . PHP_EOL; 
} 
mail($to, $subject, $message); 
?> 

답변

0

PHP에서 아무 것도 출력하지 않았으므로 리디렉션 할 헤더 만 보낼 수 있습니다.

<?php 

// ... send email 

header('Location: /backToMyForm.html'); 

?> 
+0

감사합니다. – DWalk

관련 문제