【发布时间】:2016-08-02 13:42:28
【问题描述】:
关于我今天早些时候提出的一个问题,我在下面发布了代码。
问题是我如何在一个表单/一个按钮上执行两个操作。有人推荐了 AJAX,我也做了一些研究,但解决方案对我来说不是很清楚。
当前,用户单击 orderbelow.php 上的按钮,然后向网站所有者 (send-order.php) 发送一封电子邮件,然后用户被发送到 completeyourorder.php。在这里,他们单击将他们发送到贝宝的表单上的按钮。
我想删除那个额外的步骤,这样当他们点击 orderbelow.php 时,电子邮件会发送给所有者,而用户会发送到 paypal(请记住,如图所示,两位信息会发送到 paypal 网页下面,即服务和价格)。
我是一个相对缺乏经验的编码员。我可以看到这里已经有类似的问题,但到目前为止还无法确定在我的特定情况下我需要做什么。
谢谢。
这是orderbelow.php的表单代码
<p>
<b>Personalised <?php echo $_GET['service']; ?></b>
<b>Price: £<?php echo $_GET['p'];?></b>
</p>
<form name="orderform" action="send-order.php" onsubmit="return validateForm()" method="post">
<p>Name<br /><input name="clientname" value="<?echo $clientname;?>" type="text" style="width: 350px;" /></p>
<p>Email<br /><input name="email" value="<?echo $email;?>" type="text" style="width: 350px;" /></p>
<p>Date of Birth <i>(dd/mm/yyyy)</i><br /><input name="dateofbirth" value="<?echo $dateofbirth;?>" type="text" style="width: 350px;" /></p>
<p>Please tell me any questions you want covered in your session<br /><textarea name="questions" style="width: 500px; height: 200px;"><?echo str_replace("<br />","\r\n",$questions);?></textarea></p>
<p>Please tell me the first name of anyone you are asking about and describe any other relevant details you wish to share<br /><textarea name="comments" style="width: 500px; height: 200px;"><?echo str_replace("<br />","\r\n",$comments);?></textarea></p>
<p><br /><input type="hidden" name="service" value="<?
echo $_GET['service'];
?>" />
<input type="hidden" name="p" value="<?
echo $_GET['p'];
?>"
/>
<input type="submit" value="Order now" /></p>
</form>
这是 completeyourorder.php 的表单代码。它发送两条数据来填充 Paypal 结帐,即服务“服务”和价格“p”。
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"><p><input type="image" src="images/addtobasket.gif" name="submit" alt="Make payments with PayPal - fast, free and secure!" /><img alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1" /><input type="hidden" name="add" value="1" /><input type="hidden" name="cmd" value="_cart" /><input type="hidden" name="business" value="xxxx@xxxxxx.co.uk" /><input type="hidden" name="item_name" value="<?php
echo $_GET['service'];
?>" /><input type="hidden" name="amount" value="<?php
echo $_GET['p'];
?>" /><input type="hidden" name="no_note" value="1" /><input type="hidden" name="currency_code" value="GBP" /><input type="hidden" name="bn" value="PP-ShopCartBF" /></p></form>
【问题讨论】:
-
你应该编辑stackoverflow.com/posts/38719314/edit你的另一个问题stackoverflow.com/q/38719314而不是你现在使用的代码。这(几乎)构成转发。