2014-09-13 3 views
-2
if (isset($_REQUEST['email'])) { 

    //Email information 
    $admin_email = "[email protected]"; 

    $name = $_REQUEST['name']; 

    $email = $_REQUEST['email']; 

    $subject = $_REQUEST['subject']; 

    $comment = $_REQUEST['comment']; 




    //send email 

    mail($admin_email, $name, "$subject", $comment, "From:" . $email); 

    //Email response 

    echo "Thank you for contacting us!"; 
    } 

    //if "email" variable is not filled out, display the form 

    else { 

      ?> 

<form method="post"> 

            <div> 
           <span><input name="name" type="text" class="textbox" value="Name:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name*';}"></span> 
          </div> 

          <div> 
           <span><input name="email" type="text" class="textbox" value="Email:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email*';}"></span> 
          </div> 




          <div> 
           <span><input name="subject" type="text" class="textbox" value="mobile:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'subject and phone*';}"></span> 
          </div> 

          <div> 
           <span><textarea name="comment" value="Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message*';}">Message</textarea></span> 
          </div> 

          <div> 
           <span><input type="submit" value="Submit"></span> 
          </div> 
<?php } ?> 
+1

무엇이 문제입니까? '작동하지 않습니다. '당신의 문제를 말하지 않습니다. – SuperDJ

+0

이 코드를 실행하면 어떻게 될까요? 오류? 아무것도? 잘못된 사람이 이메일을 받습니까? 아무도하지 않니? 잘못된 텍스트가 전송됩니까? – andrewsi

+0

내가 지정한 이메일을받지 못함 $ admin_email = "[email protected]"; –

답변

0

mail()에 대한 잘못된 매개 변수가 있습니다. 이 밖으로 시도 : 그들은 당신이 $to, $name, $subject, $message (선택적 매개 변수를 제외)에 있었을 때 $to, $subject, $message을 할 필요가

mail($admin_email, $subject, $comment, "From: " . $email); 

.

+0

하지만 그것에 5 개의 변수를 추가하고 싶습니다. 왜 내가이 메일을 사용할 수 없는지 ($ admin_email, $ name, $ subject, $ comment, "From :". $ email); mail ($ admin_email, $ 제목, $ 의견, "보낸 사람 :". $ 이메일); 이 기능은 아직 작동하지 않습니다.이 [email protected]에 이메일을 보내지 않았습니다. –

+0

메시지에 이름을 추가 할 수는 있지만 별도의 매개 변수로 추가 할 수는 없습니다. 'mail ($ admin_email, $ subject, $ name. "은"$ comment ","From : ". $ email);'이 (가) 쓸 것입니다. 그것이 단지 하나의 매개 변수 인 방법에 주목하십시오. –

+0

mail ($ admin_email, $ subject, $ name. "다음과 같이 썼습니다 :". $ comment, "From :". $ email); 이 기능은 여전히 ​​작동하지 않습니다. ( 스스로 시도하고 알려주세요. –

관련 문제