Html Paypal 付款并同时向用户发送电子邮件

我正在开发一个使用 PayPal 作为支付系统的网站。但我有一个问题。我想要发生的是,当我单击贝宝按钮时,它将带我进入一个新页面,客户可以在其中购买我的产品(这完全正常)。但我还想发送一封电子邮件。我弄清楚了电子邮件部分,但我无法弄清楚在将客户端重定向到 paypal 页面的同时运行代码。

代码笔

这是处理电子邮件的按钮:

<button formaction="/contact" type="submit" class="paypal-btn-check" onclick="simple_gaming_radio_check();">

这是将用户重定向到 paypal 页面的代码:

<input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="cmd" value="_s-xclick">
          <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="hosted_button_id" value="W6SHV472B68TC">
          <input type="submit" formaction="https://www.paypal.com/cgi-bin/webscr" name="submit">

网页代码

<body>

<section>

    <div class="contact-container">

        <h1>Contact</h1>

        <form method="post">

            <div class="contact-input-container">

                <div>

                    <input formaction="/contact" name="email" class="contact-input contact-email" type="text" placeholder="name@gmail.com" autocomplete="off">

                </div>

                <div>

                    <input formaction="/contact" name="subject" class="contact-input contact-subject" type="text" placeholder="subject.." autocomplete="off">

                </div>

                <div>

                    <textarea formaction="/contact" name="message" class="contact-input contact-message" type="text" placeholder="message.."></textarea>

                </div>

            </div>

            <button formaction="/contact" type="submit" class="paypal-btn-check" onclick="simple_gaming_radio_check();">

              <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="cmd" value="_s-xclick">

              <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="hosted_button_id" value="W6SHV472B68TC">

              <input type="submit" formaction="https://www.paypal.com/cgi-bin/webscr" name="submit">

            </button>

        </form>

    </div>

</section>


ABOUTYOU
浏览 241回答 1
1回答

万千封印

解决方案是通过 Javascript 中的 onclick 事件调用发送电子邮件函数。&nbsp; &nbsp; <body>&nbsp; &nbsp; <section>&nbsp; &nbsp; <div class="contact-container">&nbsp; &nbsp; &nbsp; &nbsp; <h1>Contact</h1>&nbsp; &nbsp; &nbsp; &nbsp; <form method="post">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="contact-input-container">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input formaction="/contact" name="email" class="contact-input contact-email" type="text" placeholder="name@gmail.com" autocomplete="off">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input formaction="/contact" name="subject" class="contact-input contact-subject" type="text" placeholder="subject.." autocomplete="off">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <textarea formaction="/contact" name="message" class="contact-input contact-message" type="text" placeholder="message.."></textarea>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <button formaction="/contact" type="submit" class="paypal-btn-check" onclick="simple_gaming_radio_check();">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="cmd" value="_s-xclick">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="hosted_button_id" value="W6SHV472B68TC">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" onclick="sendMail()" formaction="https://www.paypal.com/cgi-bin/webscr" name="submit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </button>&nbsp; &nbsp; &nbsp; &nbsp; </form>&nbsp; &nbsp; </div></section>你的 JavaScript 代码将是这样的&nbsp; &nbsp;function sendMail(){&nbsp; &nbsp; &nbsp; //Your sending mail code will go here&nbsp; &nbsp; &nbsp; alert("Mail Sent")&nbsp; &nbsp;}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5