2013-10-16 9 views
0

PHP 문의 양식을 설정하려고합니다. "보내기"를 클릭하면 감사하다는 말을 듣고 홈페이지로 리디렉션됩니다. 이것은 PHP와 HTML에 대한 내 스크립트입니다. 그 몇 줄은 조정이 필요하지만 정확하게는 모르겠다. mail.php 파일을 내 웹 사이트 디렉토리에 업로드했습니다.PHP 문의 양식 문제 (리디렉션)

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$call = $_POST['call']; 
$website = $_POST['website']; 
$priority = $_POST['priority']; 
$type = $_POST['type']; 
$message = $_POST['message']; 
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message"; 
$recipient = "[email protected]"; 
$subject = "Contact Form"; 
$mailheader = "From: $email \r\n"; 
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
if(mail($recipient, $subject, $formcontent, $mailheader)) 

    { 
     header("Location: http://www.darthvixcustomsabers.com/index.html"); 
     exit; 
    } 
    else 
    { 
     die("Error!"); 
    } 
echo "Thank You!" . " -" . "<a href='index.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>"; 

?> 


<!doctype html> 
<html> 
<head> 
<title> DV Custom Sabers </title> 
<meta charset="utf-8"> 
<link type="text/css" rel="stylesheet" href="style/kotorsale.css" /> 
<meta name="viewport" content="width=device-width" /> 


</head> 
<div class="header"><a href="index.html">Darthvix Custom Sabers</a></div> 

<div class="header1">DV Custom Sabers is the place to go for your saber needs!</div> 

<div class="logo"><a href="index.html"><img src="images/logo.png" alt="schedule" height="200" width="350" border="0"></a></div> 

<ul id="nav"> 
    <li><a href="index.html">Home</a></li> 
    <li><a href="aboutme.html">About Me</a></li> 
    <li><a href="services.html">Services</a></li> 
    <li><a href="Gallery.html">Gallery</a></li> 
    <li><a href="kotorsale.html">For Sale</a></li> 
    <li><a href="buildlog.html">Build Log</a></li> 
    <li><a href="contact.html"> Contact Us</a></li> 
</ul> 
<div id="form"> 
<<form action="mail.php" method="POST"> 

<p>Name</p> <input type="text" name="name"> 

<p>Email</p> <input type="text" name="email"> 


<p>Priority</p> 

<select name="priority" size="1"> 

<option value="Low">Low</option> 

<option value="Normal">Normal</option> 

<option value="High">High</option> 

<option value="Emergency">Emergency</option> 

</select> 

<br /> 

<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br /> 

<input type="submit" value="Send"><input type="reset" value="Clear"> 

</form> 

</div> 
</body> 
</html> 
+2

'$ recipient = "horgantm @ gmail.com

0

아무도 리디렉션하지 않는 것이 문제 일 수 있습니다.

나는이

 

    if(mail($recipient, $subject, $formcontent, $mailheader)) 
    { 
     header("Location: http://www.example.com/home.php?successfulySent"); 
     exit; 
    } 
    else 
    { 
     die("Error!"); 
    } 

처럼 그리고 당신은 사용자가 리디렉션 할 페이지에 코드를 편집하는

 

    if(isset($_GET['successfulySent'])) 
     echo "Thank you for sendinf a message!"; 

편집 :

내가 원하지 않는 우리는 오해를받습니다.

리디렉션과 관련하여 명세서 …and redirects you to the home page.…을 작성 했으므로이 조건이 작성되었으며 귀하의 코드에는이 조건이 없습니다. 그것은 스크립트 이후, 지금 useess입니다 중 하나 사용자를 리디렉션 또는 다음 메시지 Error!

의 URL과 정지

당신은 질문에 당신의 코드를 편집 할 수 있지만 당신은 마지막 줄 ( echo "Thank You!" . " -" .…)를 제거 잊어 버린 매개 변수 ?successfulySent은 스크립트에서 중요한 역할을합니다. 여기서 스크립트를 처리해야하는 곳으로 리디렉션하고 있습니다.

Location URL을 http://www.darthvixcustomsabers.com/index.php?successfulySent으로 변경하십시오.

그리고 php 확장명을 작성했습니다. 예, PHP 파일 유형으로이 파일을 가져와야합니다. PHP 조건을 배치하기 때문입니다. 대부분의 경우, index.htmlindex.php

으로 바꿉니다. 여기서 두 번째 조건은 메시지를 표시 할 위치입니다.

<?php if(isset($_GET['successfulySent'])):?> 
    <div class="message" id="message-sent"> 
     <p>Your message has been successfuly sent to our team...</p> 
    </div> 
<?php endif;?> 
+0

그래서 if (isset ($ _ GET [ 'successfulySent'])) echo "sendinf 메시지를 보내 주셔서 감사합니다!"; 내 홈페이지로 리디렉션하고 내 목록에있는 다른 항목으로 PHP를 편집하려면 내 index.html에? – Terry

+0

좋아요. 리디렉션 할 수있게되었지만, 일단 보내기를 클릭 한 다음 리디렉션을 보내 주셔서 감사드립니다. – Terry

+0

나는 당신이 리다이렉트를 원한다는 것을 읽었지 만, PHP 코드에 그것을 추가하지 않았었다. :) –