2013-10-12 2 views
-2

안녕하세요, 저는 PHP를 조금 배우기 시작했으며 완성 된 양식의 정보를 전자 메일로 보낼 수 있는지 궁금합니다. 나는 아래에 나열된 코드를 가지고 있지만, 그것이 옳지 않다는 것을 안다. 어떤 도움도 감사 할 것이다!이메일로 완성 된 양식 정보 보내기

PHP :

<?php 

    $email = $_REQUEST['clientEmail'] ; 
    $subject = "New Order"; 
    $name = $_REQUEST['clientName'] ; 
    $articleAmount = $_REQUEST['articleNum']; 
    $wordAmount = $_REQUEST['wordNum']; 
    $topic = $_REQUEST['topic']; 
    $info = $_REQUEST['addInfo']; 
    mail("[email protected]", $subject, 
    "Name:" . $name . "<br/>" . "Amount of Articles:" . $articleAmount . "<br/>" . "Amount of Words:" . $wordAmount . "<br/>" . "Topic:" . $topic . "<br/>" . "Additional Information:" . $info, "From:" . $email); 
    echo "Thank you for ordering!"; 

?> 

HTML :

<form action="order.php"> 

    <fieldset id="client" > 

     <legend>Client Information</legend> 
     <label for="clientName">Name:</label><input type="text" name="clientName" id="clientName" tabindex="1"/> 
     <label for="clientEmail">Email:</label><input type="email" name="clientEmail" id="clientEmail" tabindex="2"/> 

    </fieldset> 

    <fieldset id="order"> 

     <legend>Order Information</legend> 
     <label for="articleNum">Number of Articles</label><input type="text" name="articleNum" id="articleNum" tabindex="3"/> 
     <label for="wordNum">Words per Article</label><input type="text" name="wordNum" id="wordNum" tabindex="4"/> 
     <label for="topic">Topics</label><input type="text" name="topic" id="topic" tabindex="5"/> 
     <label for="addInfo">Additional Info</label><input type="text" name="addInfo" id="addInfo" tabindex="6"/> 

    </fieldset> 

    <fieldset> 

     <button type="submit">Submit!</button> 

    </fieldset> 
</form> 
+2

...? 질문이 뭐야? –

+0

당신은 실제로 문제가 무엇인지 말하지 않았습니다 - 그것이 옳지 않다는 것을 어떻게 아십니까? –

답변

0

사용 PHP mail 또는 PHPMailer (꽤 잘 작동)? PHPMailer 라이브러리 사용

+0

그게 내가 사용하려고했는데 내가 잘못 사용하고있는 것 같아. – kduan

0

:. 내가 양식에 사용자가 입력 할 것을이 정보를 전송하는 방법을없는 것으로 나타났습니다 https://github.com/PHPMailer/PHPMailer


define('PROJECT_ROOT', '/path/to/your/root/'); //Different for different webhosts or self hosted environments 

require (PROJECT_ROOT . 'PHPMailer-master/class.phpmailer.php'); 

$mail = new PHPMailer(); 
$mail->IsSMTP(); 
$to = $_POST['clientEmail']; //Email dervied from POST data. 

$mail->Host  = "mail.example.com"; //If you haven't got an SMTP server, use Gmail's free one. 
$mail->SMTPDebug = 0; 
$mail->SMTPAuth = true; 
$mail->Port  = 25; 
$mail->Username = "[email protected]"; 
$mail->Password = "somePass"; 
$mail->From  = '[email protected]'; 
$mail->FromName = 'My Website'; 
$mail->WordWrap = 50; 
$mail->isHTML(true); // Or false 
$mail->addReplyTo('[email protected]', 'Support'); 

$mail->Subject = 'Message subject here'; 
$mail->addAddress($to); 

$mail->Body = ""; // Message body using HTML here. (Remove if $mail->isHTML(); is false) 
$mail->AltBody = " 

Client: " . $_POST['clientName'] . " //Again: derived from POST data. 
Email: " . $to . " //We defined this variable before as clientEmail 

Number of Articles: " . $_POST['articleNum'] . " 
Words per Article: " . $_POST['wordNum'] . " 
Topics: " . $_POST['topic'] . " 
Additional Info: " . $_POST['addInfo'] . " 


"; 

    if(!$mail->send()) { 
     echo 'Message could not be sent.'; 
     echo "Mailer Error: " . $mail->ErrorInfo; 
     exit; 
    } else { 
      echo "Mail sent!"; 
     } 

<form action="order.php"> 

그것은해야한다 :

<form action="order.php" method="POST"> 

희망을 얻으십시오!

+0

도움을 주셔서 감사합니다.이 방법을 사용해 봤지만 그 코드는 모두 웹 사이트의 텍스트로 표시됩니다. 어떤 아이디어? – kduan

+0

예.

관련 문제