2009-08-01 7 views
1

내가 여기서 내가 원하는 것만으로도 충분할 수 있기를 바랍니다. 내가 가지고있는 것은 내가 개발중인 이메일 클라이언트 애플리케이션을위한 HTML을 포함하는 함수이다. 앱의이 부분은 일반적인 전달, 답장 및 "전체 답장"양식을 사용합니다. 그들은 기본적으로 모두 같기 때문에, 나는 희박 경로를 찾아서 이것을 처리하기 위해 하나의 함수를 사용한다고 생각했습니다. 위에서 언급 한 3 가지 작업 사이에서 볼 수있는 유일한 차이점은 모두에 대한 회신에서 양식의 참조 부분에 여러 개의 이메일 주소가 있다는 점입니다. 포워드의 경우, no (cc)와 (to) 상자는 공백이어야합니다. 이 모든 기능을 나타낼 필요가 있으며 가장 좋은 방법은 무엇인지 혼란 스럽습니다. 아무도 어떤 도움을 제공 할 수 있습니까? 감사.하나의 html 양식을 사용하여 여러 작업을 처리하는 방법

내가 확실히 게시 할 수있는 html이 필요하다. 나는 단지 빛을 시작하고 싶었다.

편집 : 양식 유효성 검사가 실패한 경우 사용자가 양식을 제출하면 POST 값이 표시됩니다.


function compose($type,$contents=null) 
{ 
    echo' 
     <tr> 
      <td> 
      <tr> 
       <td valign="top"> 
       <form method="post" action=""> 
        <table width="100%" cellpadding="0" cellspacing="0" border="0" id="reply"> 
        <tr> 
         <td><h2>'.$type.'</h2></td> 
        </tr> 
        <tr> 
         <td width="1%" valign="top" nowrap><b>To:</b><br><input name="to" id="focus" title="Enter a single system user here" value="" type="text" size="64"></td> 
        </tr> 
        <tr> 
         <td nowrap><b>Cc:</b><br><input name="cc"" value="" type="text" size="64"></td> 
        </tr> 
        <tr> 
         <td nowrap><b>Subject:</b><br><input name="subject" title="Enter your subject here" value="" type="text" size="64" maxlength="30"></td> 
        </tr> 
        <tr> 
         <td valign="top"><b>Message:</b><br><textarea name="message" title="Enter your message here" rows="5" cols="50" wrap="virtual"></textarea></td> 
        </tr> 
        <tr> 
         <td>&nbsp;</td> 
        </tr> 
        <tr> 
         <td><input type="hidden" name="id" value=""><input type="submit" name="send" value="Send"></td> 
        </tr> 
        </table> 
       </form> 
       </td> 
      </tr> 
      </td> 
     </tr>'; 
} 
+0

다른 사람이 나를 도울 수 있도록 이미 시도한 코드를 게시하는 것이 좋습니다. – random

+0

나는 이것이 당신이해야 할 것보다 더 어렵게 만들 것이라고 생각합니다. 대부분의 현대 이메일 클라이언트는 항상 사용자가받는 사람, 참조 및 숨은 참조를 수정할 수 있습니다. 하나의 양식만으로도 충분합니다. 전달, 응답 및 응답 모두의 유일한 차이는 필드의 사전 채우기입니다. – doomspork

답변

0

는 편집 : 게시 된 코드의 예 수정 (나는 모든 다른 경우를 추가 또는 단지 개념을 보여주는, 정말 출력을 변경하지 않은 - 모든 것을 여기에 대답의 유형에 대한 검사입니다 상기 '에서'POST 값에 대한 검사.)

function compose($type,$contents=null) 
{ 
    $toValue = ''; 
    if(isset($_POST['to'])) 
    { 
     // Might want to actually validate this to prevent XSS, but this is just a basic example 
     $toValue = $_POST['to']; 
    } 

    echo' 
     <tr> 
      <td> 
      <tr> 
       <td valign="top"> 
       <form method="post" action=""> 
        <table width="100%" cellpadding="0" cellspacing="0" border="0" id="reply"> 
        <tr> 
         <td><h2>'.$type.'</h2></td> 
        </tr>'; 

    if($type == "Reply") { 
     echo' 
        <tr> 
         <td width="1%" valign="top" nowrap><b>To:</b><br><input name="to" id="focus" title="Enter a single system user here" value="' . $toValue . '" type="text" size="64"></td> 
        </tr> 
        <tr> 
         <td nowrap><b>Cc:</b><br><input name="cc"" value="" type="text" size="64"></td> 
        </tr>'; 
    } 

    echo' 
        <tr> 
         <td nowrap><b>Subject:</b><br><input name="subject" title="Enter your subject here" value="" type="text" size="64" maxlength="30"></td> 
        </tr> 
        <tr> 
         <td valign="top"><b>Message:</b><br><textarea name="message" title="Enter your message here" rows="5" cols="50" wrap="virtual"></textarea></td> 
        </tr> 
        <tr> 
         <td> </td> 
        </tr> 
        <tr> 
         <td><input type="hidden" name="id" value=""><input type="submit" name="send" value="Send"></td> 
        </tr> 
        </table> 
       </form> 
       </td> 
      </tr> 
      </td> 
     </tr>'; 
} 

(원본 문의) 폼의을 처리 결과이 함수이거나 애초에 형태를 표시? 당신의 질문은 당신이 말하고있는 과정의 어느 시점에 대해 약간 불분명합니다.

+0

답장을 보내 주셔서 감사합니다. 이 함수는 html을 다시 폼의 다른 부분에 에코합니다. –

+0

나는 약간의 if 조건을 사용하고 있지만 실제로는 추악합니다. 내가 그것을 얻을 수있을 때 나는 깨끗한 것을 좋아한다. :) –

+0

나는 당신이 이미 가지고있는 것을 올리는 것이 분명하다. – Amber

관련 문제