2015-01-13 2 views
-1

내 문의 양식이 작동하지 않는 이유를 파악하는 데 문제가 있습니다. 필자는 PHP에 비교적 익숙하지 않고 모든 것을 볼 수 있지만 모든 것이 링크되어 있지만 전자 메일을 보내려면 지정된 배달 주소로 아무 것도 보내지 않습니다. 어떤 도움을 주시면 감사하겠습니다 !! 고맙습니다!! 내 코드는 다음과 같습니다 :간단한 PHP 문의 양식 관련 문제

HTML

<table width="400" border="0" align="left" cellpadding="0" cellspacing="1"> 
<tr> 
<td><form name="form1" method="post" action="mail.php"> 
<table width="100%" border="0" cellspacing="1" cellpadding="3"> 
<tr> 
<td width="16%">Subject</td> 
<td width="2%">:</td> 
<td width="82%"><input name="subject" type="text" id="subject" size="50"></td> 
</tr> 
<tr> 
<td>Message</td> 
<td>:</td> 
<td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> 
</tr> 
<tr> 
<td>Name</td> 
<td>:</td> 
<td><input name="name" type="text" id="name" size="50"></td> 
</tr> 
<tr> 
<td>Email</td> 
<td>:</td> 
<td><input name="customer_mail" type="text" id="customer_mail" size="50"></td> 
</tr> 
<tr> 
<td>&nbsp;</td> 
<td>&nbsp;</td> 
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> 
</tr> 
</table> 
</form> 
</td> 
</tr> 
</table> 

PHP

<?php 

// Contact subject 
$subject ="$subject"; 

// Details 
$message="$detail"; 

// Mail of sender 
$mail_from="$customer_mail"; 

// From 
$header="from: $name <$mail_from>"; 

// Enter your email address 
$to ='[email protected]'; 
$submit=mail($to,$subject,$message,$header); 

// Check, if message sent to your email 
// display message "We've recived your information" 
if($submit){ 
echo "Thank you for contacting us at Allstar Therapies, Inc.<br /> We will be in touch shortly!"; 
} 
else { 
echo "ERROR"; 
} 
?> 
+0

양식을 제출하면 무엇을 얻게됩니까? 빈 페이지가 있습니까? 텍스트가있는 흰색 페이지 (있는 경우 어떤 텍스트?) - 또는 무엇? 방화범이 끌려가 디버그 도움이 될 것입니다. - –

+0

"ERROR"또는 "Thank you ..."부분에 입력 하시겠습니까? $ var를 ""에 묶을 필요는 없습니다! – Spoke44

답변

0

아직 게시물 변수에 PHP 변수 (IE $subject)을 설정하지 않았습니다. $ _POST 변수를 사용하도록 PHP 변수를 변경하십시오.

<?php 

// Contact subject 
$subject = $_POST['subject']; 

// Details 
$message= $_POST['detail']; 

// Mail of sender 
$mail_from= $_POST['customer_mail']; 

// From 
$header="from: {$_POST['name']} <{$_POST['mail_from']}>"; 

// Enter your email address 
$to ='[email protected]'; 
$submit=mail($to,$subject,$message,$header); 

// Check, if message sent to your email 
// display message "We've recived your information" 
if($submit){ 
echo "Thank you for contacting us at Allstar Therapies, Inc.<br /> We will be in touch shortly!"; 
} 
else { 
echo "ERROR"; 
} 
?> 
0

이 라인은 잘못 : 당신은 자신에 변수를 할당하려는

// Contact subject 
$subject ="$subject"; 

// Details 
$message="$detail"; 

// Mail of sender 
$mail_from="$customer_mail"; 

// From 
$header="from: $name <$mail_from>"; 

. 시도 :

$subject = $_POST['subject']; 
$message = $_POST['detail']; 

당신은 $ _POST 변수를 사용할 필요가
0

:

// Contact subject 
$subject = isset($_POST["subject"]) ? ($_POST["subject"]) : ""; 
1

PHP 코드 나에게 잘못된 것입니다. 이것은 수정 된 버전입니다.

<?php 

// Contact subject 
$subject = $_POST['subject']; 

// Details 
$message = $_POST['detail']; 

// Mail of sender 
$mail_from = $_POST['customer_mail']; 

// From 
$header = "from: " . $_POST['name'] . "<" . $_POST['customer_mail'] . ">"; 

// Enter your email address 
$to = '[email protected]'; 
$submit = mail($to, $subject, $message, $header); 

// Check, if message sent to your email 
// display message "We've recived your information" 
if ($submit) { 
    echo "Thank you for contacting us at Allstar Therapies, Inc.<br /> We will be in touch shortly!"; 
} else { 
    echo "An error has been encountered while sending your message. We sincerely apologize and ask you to try again. If that fails as well, please contact us at XYZ-Y234-SADF"; 
} 

변수가 초기화되지 않았습니다. 이 기호는 문자열의 시작과 끝을 표시합니다.

0

$ _GET에 의해 $ _POST/GET 매개 변수로 POST 매개 변수에 액세스 할 수 있습니다. 먼저 리디렉션이 올바른지 확인하십시오. 유형 : 에코 "환영"; mail.php

리디렉션이 작동하면 모든 게시 매개 변수가 인쇄됩니다. print_r ($ _ POST);

마지막 하나

에 의해 하나를 얻을 수 있습니다 $ 변수 = $ _POST [ 'input_name_from_form'];

희망 사항이 문제의 해결책입니다.