2017-11-30 17 views
0

私はそれがとても簡単だと確信していますが、私はそれを解決することはできません。 SMTP経由で送信するように変更した単純なHTML - > PHPフォームがあります。それはうまく動作しますが、$ _POST型を挿入する方法を考えることはできません(テーブルに入っています;それが重要かどうかはわかりません)。

これは、ユーザーが情報を入力するというのが私の私のHTMLフォームです:

<form id="test" method="post" action="employment-applicationreceived.php"> 
<div class="backgroundform"> 
     <li id="li_1" > 
     <label class="description2" for="element_1">Name: </label> 
     <input id="req_name" name= "req_name" class="element text" maxlength="255" size="28" value=""/> 
    </form>  

そして、これが情報を送信.PHPフォームです:

<?php 
require_once "Mail.php"; 
require_once "Mail/mime.php"; 

$from = "Test <[email protected]>"; 
$to = "Test <[email protected]>"; 
$subject = "Test HTML email using PHP Pear w/ SMTP\r\n\r\n"; 
$text = "This is a text test email message"; 
$html = "<html><body><html><body> 
<strong>PERSONAL INFORMATION</strong> 
<table> 
<tr style='background: #999;'><td height='2'></td><td> 
<tr><td>First Name: </td><td width='500'>$req_name = $_POST['req_name'];</td> 
</table></body></html>"; 

$crlf = "\n"; 

$mime = new Mail_mime($crlf); 
$mime->setTXTBody($text); 
$mime->setHTMLBody($html); 

$host = "hostname"; 
$port = "25"; 
$username = '[email protected]'; 
$password = '***'; 

$headers = array ('From' => $from, 
    'To' => $to, 
    'Subject' => $subject); 
$smtp = Mail::factory('smtp', 
    array ('host' => $host, 
    'auth' => true, 
    'username' => $username, 
    'password' => $password)); 


$body = $mime->get(); 
$headers = $mime->headers($headers); 

$mail = $smtp->send($to, $headers, $body); 

if (PEAR::isError($mail)) { 
    echo(" 
    " . $mail->getMessage() . " 
    "); 
} else { 
    echo(" 
    Message successfully sent! 
    "); 
} 
?> 

答えて

2

あなたはすぐ外の場所のポストの値を持っています以下のようにあなたの$html .change ""の:

$html = "<html><body><html><body> 
<strong>PERSONAL INFORMATION</strong> 
<table> 
<tr style='background: #999;'><td height='2'></td><td> 
<tr><td>First Name: </td><td width='500'>".$_POST['req_name']."</td> 
</table></body></html>"; 
+0

ありがとうございました!それがまさに必要なものでした。私はこれを正しいものとしてマークしました。 – IVCatalina