2012-09-11 2 views
0

전자 메일 본문에 HTML 양식을 복사하려고합니다. 아래는 양식이 이미 PHP 파일에있는 코드이지만 사용자가 HTML 양식 파일을 제출하면 그 사이의 모든 양식 데이터가 숨겨지지 않은 상태로 전자 메일 본문에 복사됩니다 (비활성화 된 요소로). 또한 파일 첨부 필드가있는 경우 전자 메일에 첨부해야합니다.전자 메일에 HTML 양식 복사 PHP

<?php 
// multiple recipients 
$to = '[email protected]' . ', '; // note the comma 
$to .= '[email protected]'; 

// subject 
$subject = 'Birthday Reminders for August'; 

// message 
$message = ' 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 


<title>Untitled Document</title> 
</head> 

<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF"> 
<table cellpadding="0" cellspacing="0" border="0" width="440"> 

    <tr><td style="height:10px"></td></tr> 
    <tr> 
     <td colspan="2" style="text-align:justify; line-height:15px;" class="body"> 

     <form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data"> 
     <table cellpadding="0" cellspacing="0" border="0" width="100%"> 
      <tr> 
      <td width="23%" class="body"> Name</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><input type="text" name="strname" class="textfield"></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> Address</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><textarea cols="16" name="straddress"></textarea></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> City</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><input type="text" name="strcity" class="textfield"></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> State</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><input type="text" name="strstate" class="textfield"></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> Contact No</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><input type="text" name="strno" class="textfield"></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> Email</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><input type="text" name="stremail" class="textfield"></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> Comments</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><textarea cols="16" name="strcomments"></textarea></td> 
     </tr> 
     <tr><td style="height:3px"></td></tr> 
     <tr> 
      <td width="23%" class="body"> Resume</td> 
      <td width="3%" class="body">:</td> 
      <td width="74%"><input type="file" name="strresume"></td> 
     </tr> 
     <tr><td style="height:10px"></td></tr> 
     <tr> 

     </tr> 

     </table> 
    </form> 

</td> 
    </tr> 
    <tr> 
     <td colspan="2" align="center"> </td> 
    </tr> 
    </table> 
</body> 
</html> 
'; 

// To send HTML mail, the Content-type header must be set 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; 
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

// Mail it 
mail($to, $subject, $message, $headers); 
?> 
+0

나는 모든 이메일 클라이언트가 귀하의 이메일에 양식을 접수하고 또한 게시물 데이터를 전송할 것이라고 생각하지 않습니다. –

+0

나는이 권리를 얻고 있는가? 이메일 본문에 공식을 추가 하시겠습니까? 여기에 혁신에 대해 말하기 ... – dbf

+0

이메일 본문에 선택된 양식 데이터를 복사하고 싶습니다. 왜 문제가 있습니까? –

답변

0

양식이 웹 사이트에서 제출되었다고 가정하고 제출 가능한 양식을 전자 메일로 작성하려고하지는 않습니다. 양식에 제출 된 데이터를 복사하려면 $ _POST [ ""]; 반드시 데이터를 얻는 가장 좋은 방법 일 것입니다. 이메일이 수신자의받은 편지함에 도착하면 데이터는 조작 할 수 없지만 이메일에서 제출할 수있는 양식을 만들려고하지는 않는다고 가정합니다.

웹 사이트에 대한 귀하의 형태는 괜찮다고 : 양식 존재의 제출 값 발생합니다

<?php 
// multiple recipients 
$to = '[email protected]' . ', '; // note the comma 
$to .= '[email protected]'; 

// subject 
$subject = 'Birthday Reminders for August'; 

$strName = $_POST["strname"]; //assigns strname from form to PHP variable 
$strAddress = $_POST["straddress"]; 
$strCity = $_POST["strcity"]; 
$strState = $_POST["strstate"]; 
$strNumber = $_POST["strnumber"]; 
$strEmail = $_POST["stremail"]; 
$strComments = $_POST["strcomments"]; 
$strResume = $_POST["strresume"]; 
$lineBreak = "<br />\n\"; //adds carriage return to break up your message 

$message = "Name: ".$strName.$lineBreak."Address: ".$strAddress.$lineBreak."City: ".$strCity.$lineBreak."State: ".$strState.$lineBreak...for the rest of your variables; 

// To send HTML mail, the Content-type header must be set 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; 
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

// Mail it 
mail($to, $subject, $message, $headers); 
?> 

:

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 


<title>Untitled Document</title> 
</head> 

<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF"> 
<table cellpadding="0" cellspacing="0" border="0" width="440"> 

<tr><td style="height:10px"></td></tr> 
<tr> 
    <td colspan="2" style="text-align:justify; line-height:15px;" class="body"> 

    <form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data"> 
    <table cellpadding="0" cellspacing="0" border="0" width="100%"> 
     <tr> 
     <td width="23%" class="body"> Name</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><input type="text" name="strname" class="textfield"></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> Address</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><textarea cols="16" name="straddress"></textarea></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> City</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><input type="text" name="strcity" class="textfield"></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> State</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><input type="text" name="strstate" class="textfield"></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> Contact No</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><input type="text" name="strno" class="textfield"></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> Email</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><input type="text" name="stremail" class="textfield"></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> Comments</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><textarea cols="16" name="strcomments"></textarea></td> 
    </tr> 
    <tr><td style="height:3px"></td></tr> 
    <tr> 
     <td width="23%" class="body"> Resume</td> 
     <td width="3%" class="body">:</td> 
     <td width="74%"><input type="file" name="strresume"></td> 
    </tr> 
    <tr><td style="height:10px"></td></tr> 
    <tr> 

    </tr> 

    </table> 
</form> 

</td> 
</tr> 
<tr> 
    <td colspan="2" align="center"> </td> 
</tr> 
</table> 
</body> 
</html> 

귀하의 파일 careersuccess.php은 다음과 같은 것을 포함해야 mail() 함수의 $ message 변수에있는 전자 메일에 복사됩니다.

관련 문제