wordpress页面从iframe重定向到paypal页面

时间:2011-05-31 12:07:16

标签: 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"></iframe>

                    </div>

此iframe中脚本的演示可在此处找到:http://www.phpjabbers.com/hotels-booking-system/ 我想要做的是,一旦用户点击立即预订按钮是将它们重定向到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​​pal页面而不点击立即付款?如果有人能把我放在正确的方向,那就太好了。我知道隐藏的价值必须转移到Paypal页面,我只是不知道如何制作它以便它们被延续。有任何想法吗?任何提示都会非常感激。

1 个答案:

答案 0 :(得分:0)

我一直在尝试自己解决这个问题所以我到目前为止做了什么:因为我希望一旦用户点击Book按钮就重定向到PayPal,我将隐藏的字段复制到了现在付费的部分预订按钮 - &gt;最后一部分代码的一部分:

($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> 

用户点击“预订”按钮后,代码将检查是否已使用此提交:

elseif ($_REQUEST["ac"]=='save_booking') {

然后将预订详细信息(姓名,电话,电子邮件,...)插入数据库,如下所示:

$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页面。有人可以指出我正确的方向吗?