0

I'm trying to submit data to a list in my mail chimp but also allow the user to upload a file.

Here is my code, the first chunk is the mailchimp autogenerated form which is submitted via:

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

and then it's followed by the basic code to submit a file. But at the moment both functions have a submit button. I want only one. Can anyone help?

<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>
4

1 回答 1

0

您可以通过您的 upload_file.php 文件路由 MailChimp 信息来完成此操作。

MailChimp 有一个很棒的 AP​​I,您可以使用它来将订阅者添加到列表中。您会特别想要listSubscribe() 函数。该页面上有一些很好的例子。

以下是有关 MailChimp API 的更多文档:http: //apidocs.mailchimp.com/api/2.0/

因此,在您的 HTML 中,您可能希望删除第二个提交按钮并使其成为一种带有 action="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>
于 2013-10-09T14:36:19.047 回答