wordpress页面从iframe重定向到paypal页面
我有一个与iframe集成的Wordpress页面,其中包含预订日历脚本,如下所示wordpress页面从iframe重定向到paypal页面,wordpress,iframe,Wordpress,Iframe,我有一个与iframe集成的Wordpress页面,其中包含预订日历脚本,如下所示 <div class="booking-calendar"> <iframe id="frame1" name="frame1" src="http://www.xxxxxx.co.uk/booking/frontend/" width="100%" height="450px" frameborder="0" scrolling="auto">&l
<div class="booking-calendar">
<iframe id="frame1" name="frame1" src="http://www.xxxxxx.co.uk/booking/frontend/" width="100%" height="450px" frameborder="0" scrolling="auto"></iframe>
</div>
此iframe中脚本的演示可以在以下位置找到:
我想做的是,一旦用户点击BookNow按钮,就会将他们重定向到Paypal页面。目前的设置是,他们必须点击“立即付款”按钮才能进入Paypal页面进行付款。此“立即付款”按钮的代码如下所示:
<?php
if ($deposit > 0) {
if ($_REQUEST['payment_type'] == 'paypal') {
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $SETTINGS_DB["paypal_address"]; ?>">
<input type="hidden" name="item_name" value="Booking confirmation - <?php echo $BookingID; ?>">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="amount" value="<?php echo number_format($deposit, 2, '.', ''); ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="<?php echo $Currencies[$SETTINGS_DB["currency"]]; ?>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="<?php echo $SETTINGS_DB["thankyou_page"]; ?>">
<input name="submit" type='submit' value='PAY NOW' >
</form>
<?php
header ("https://www.paypal.com/cgi-bin/webscr");
exit;
?>
我想知道如何重定向,以便用户在不点击Pay now的情况下自动转到Paypal页面?如果有人能把我引向正确的方向,那就太好了。我知道隐藏的值必须转移到Paypal页面,我只是不知道如何使其转移。有什么想法吗?任何提示都将不胜感激。我一直在尝试自己解决问题,所以到目前为止我做了什么:因为我希望在用户单击Book按钮后重定向到PayPal,所以我将Pay now表单中的隐藏字段复制到最后一位代码的part with Book button-->部分:
($deposit > 0) {
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $SETTINGS_DB["paypal_address"]; ?>">
<input type="hidden" name="item_name" value="Booking confirmation - <?php echo $BookingID; ?>">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="amount" value="<?php echo number_format($deposit, 2, '.', ''); ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="<?php echo $Currencies[$SETTINGS_DB["currency"]]; ?>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="<?php echo $SETTINGS_DB["thankyou_page"]; ?>">
<?php }
?>
<div style="float:left"><input type="submit" value="Book"></div>
<div style="clear:both"></div>
</form>
然后将预订详细信息(姓名、电话、电子邮件等)插入数据库,如下所示:
$sql = "INSERT INTO ".$TABLES["bookings"]." SET
`from` = '".Date2MySQL(SaveToDB($_REQUEST["from"]))."',
`to` = '".Date2MySQL(SaveToDB($_REQUEST["to"]))."',
`name` = '".SaveToDB($_REQUEST["name"])."',
`email` = '".SaveToDB($_REQUEST["email"])."',
`phone` = '".SaveToDB($_REQUEST["phone"])."',
`notes` = '".SaveToDB($_REQUEST["notes"])."',
`people` = '".SaveToDB($_REQUEST["people"])."',
`payment_type` = '".SaveToDB($_REQUEST["payment_type"])."',
`dt` = now()";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql.mysql_error());
$BookingID = mysql_insert_id();
$total_price = 0;
$sql = "SELECT * FROM ".$TABLES["rooms"]." ORDER BY id DESC";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
if ($_REQUEST["room_".$row["id"]]>0) {
$sql = "INSERT INTO ".$TABLES["bookings_rooms"]." SET
`booking_id` = '".$BookingID."',
`room_id` = '".$row["id"]."',
`quantity` = '".SaveToDB($_REQUEST["room_".$row["id"]])."'";
$sql_resultT = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql.mysql_error());
$total_price = $total_price + $_REQUEST["room_price_".$row["id"]]*$_REQUEST["room_".$row["id"]];
};
};
$sql = "UPDATE ".$TABLES["bookings"]." SET
`price` = '".$total_price."'
WHERE id = '".$BookingID."'";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql.mysql_error());
$deposit = $SETTINGS_DB["payment_deposit"];
$sql = "SELECT * FROM ".$TABLES["bookings"]." WHERE id='".$BookingID."'";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
$booking = mysql_fetch_assoc($sql_result);
$sql = "SELECT * FROM `".$TABLES["bookings_rooms"]."` INNER JOIN ".$TABLES["rooms"]." ON ".$TABLES["rooms"].".id = ".$TABLES["bookings_rooms"].".room_id WHERE `".$TABLES["bookings_rooms"]."`.booking_id='".$BookingID."'";
$sql_resultP = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($rooms = mysql_fetch_assoc($sql_resultP)) {
$roomsemail .= $rooms["quantity"]." x ".$rooms["room_type"].", ";
};
$message = ReadFromDB($SETTINGS_DB["email_message"]);
$search_tokens=array("{name}","{email}","{phone}","{from_date}","{to_date}","{price}","{rooms}");
$replace_tokens=array(ReadFromDB($booking["name"]),ReadFromDB($booking["email"]),ReadFromDB($booking["phone"]),MySQL2Date(ReadFromDB($booking["from"])),MySQL2Date(ReadFromDB($booking["to"])),formatCurrencyExport($booking["price"]),$roomsemail);
$message=str_replace($search_tokens,$replace_tokens,$message);
$mailheader = "From: ".$SETTINGS_DB["admin_email"]."\r\n";
$mailheader .= "Reply-To: ".$SETTINGS_DB["admin_email"]."\r\n";
$mailheader .= "Content-type: text/plain; charset=UTF-8\r\n";
mail($booking["email"], $SETTINGS_DB["email_subject"], $message, $mailheader);
if ($SETTINGS_DB["admin_email"]) {
mail($SETTINGS_DB["admin_email"], $SETTINGS_DB["email_subject"], $message, $mailheader);
}
将数据插入数据库后,我希望用户自动转到PayPal支付页面,因此我在上述代码之后插入了此代码:
header ("https://www.paypal.com/cgi-bin/webscr");
exit;
?>
现在,当我点击Book按钮时,什么都没有发生,表单消失了,所以我在页面上只有一些说明文本,但我们没有重定向到PayPal页面。有人能给我指出正确的方向吗?我一直在努力自己解决这个问题,所以到目前为止我做了什么:有人知道如何解决这个问题吗?所以我想做的是:在用户点击“Book”按钮后,来自预订表单的信息应该被插入数据库,然后用户应该被发送到paypal支付页面。指向此页面的链接是:并且它应该引入所有隐藏字段的值,以便显示正确的形式和详细信息。
header ("https://www.paypal.com/cgi-bin/webscr");
exit;
?>