2013-10-09 93 views
0

我想提交數據到我的郵件黑猩猩列表中,但也允許用戶上傳文件。如何使用1提交按鈕執行2個操作?

這裏是我的代碼,第一塊是通過提交mailchimp自動生成表格:

<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div> 

,然後它後面的基本代碼提交文件。但目前這兩個函數都有一個提交按鈕。我只想要一個。誰能幫忙?

<body> 
    <!-- Begin MailChimp Signup Form --> 
    <div id="mc_embed_signup"> 
     <form action="http://test.us7.list-manage.com/subscribe/post?u=d12b70d4bb1e08c1568d5b392&amp;id=bfb41cbf75" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> 
      <h2>Subscribe to our test mailing list</h2> 
      <div class="indicates-required"> 
       <span class="asterisk">*</span> indicates required 
      </div> 
      <div class="mc-field-group"> 
       <label for="mce-EMAIL"> 
        Email Address <span class="asterisk">*</span> 
       </label> 
       <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL"> 
      </div> 
      <div class="mc-field-group"> 
       <label for="mce-FNAME">First Name </label> 
       <input type="text" value="" name="FNAME" class="" id="mce-FNAME"> 
      </div> 
      <div class="mc-field-group"> 
       <label for="mce-LNAME">Last Name </label> 
       <input type="text" value="" name="LNAME" class="" id="mce-LNAME"> 
      </div> 
      <div class="mc-field-group input-group"> 
       <strong>Interests </strong> 
       <ul> 
        <li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li> 
        <li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1">  <label for="mce-group[5597]-5597-1">Interest 2</label></li> 
        <li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li> 
       </ul> 
      </div> 
      <div id="mce-responses" class="clear"> 
       <div class="response" id="mce-error-response" style="display:none"></div> 
       <div class="response" id="mce-success-response" style="display:none"></div> 
      </div> 
     </div> 
     <form action="upload_file.php" method="post" enctype="multipart/form-data"> 
      <label for="file">Filename:</label> 
      <input type="file" name="file" id="file"><br> 
      <input type="submit" name="submit" value="Submit"> 
      <div class="clear"> 
       <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"> 
      </div> 
     </form> 
    </form> 
</body> 
+0

你的意思是有一個按鈕來上傳文件,然後當用戶選擇一個文件中,並觸發電子郵件的按鈕? –

+0

也許一個布爾值可以做到這一點? – Loko

+0

@David Jones所以用戶填寫他們的細節並選擇一個文件(例如簡歷)。文件被髮送到公司,並將詳細信息發送到mailchimp的列表中 - 抱歉沒有解釋得好! – mattmuirhead

回答

0

您可以通過將MailChimp信息路由到upload_file.php文件來實現此目的。

MailChimp有一個很棒的API,您不僅可以將訂閱者添加到列表中,還可以使用它。你會特別想要listSubscribe() function。該頁面上有一些很棒的例子。

這裏有MailChimp的API的更多文檔:http://apidocs.mailchimp.com/api/2.0/

所以在你的HTML,你想刪除第二個提交按鈕,使一個形式的行動=「upload_file.php」。 PHP文件將上傳文件,然後使用API​​將數據提交給MailChimp。

你的HTML應該是這樣的:

<body> 
<!-- Begin MailChimp Signup Form --> 
<div id="mc_embed_signup"> 
    <form action="upload_file.php" method="post" enctype="multipart/form-data"> 
     <h2>Subscribe to our test mailing list</h2> 
     <div class="indicates-required"> 
      <span class="asterisk">*</span> indicates required 
     </div> 
     <div class="mc-field-group"> 
      <label for="mce-EMAIL"> 
       Email Address <span class="asterisk">*</span> 
      </label> 
      <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL"> 
     </div> 
     <div class="mc-field-group"> 
      <label for="mce-FNAME">First Name </label> 
      <input type="text" value="" name="FNAME" class="" id="mce-FNAME"> 
     </div> 
     <div class="mc-field-group"> 
      <label for="mce-LNAME">Last Name </label> 
      <input type="text" value="" name="LNAME" class="" id="mce-LNAME"> 
     </div> 
     <div class="mc-field-group input-group"> 
      <strong>Interests </strong> 
      <ul> 
       <li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li> 
       <li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1">  <label for="mce-group[5597]-5597-1">Interest 2</label></li> 
       <li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li> 
      </ul> 
     </div> 
     <div id="mce-responses" class="clear"> 
      <div class="response" id="mce-error-response" style="display:none"></div> 
      <div class="response" id="mce-success-response" style="display:none"></div> 
     </div> 
    </div> 
    <label for="file">Filename:</label> 
    <input type="file" name="file" id="file"><br> 

    <div class="clear"> 
     <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"> 
    </div> 
</body>