Sagepay服务器集成(NextURL问题)

I have to integrate Sagepay iframe payment system to a Prestashop eCommerce.

First of all, i'm doing all the code outside of Prestashop files to work cleanly and integrate the code without any trouble.

I create a Form with all the params that Sagepay need and I recieve. The action of that form was pointed to "Server Sagepay web". I loaded its POST returned value on a "target" iframe and i read the NextURL param.

But I can't load $nextURL param into "src" of the iframe because i don't reload or move into another page.

The solutions i tried are "cUrl" connection, Ajax connections but i don't know if i'm going right in that way...

If someone could help me explaining how to load nextURL on src attr of iframe or explain his solution/example it will help me a lot!

this is my form structure:

<form action="credit-cards.php" method="POST" id="SagePayForm" name="SagePayForm">
    <input type="hidden" name="VPSProtocol" value="2.23" />
    <input type="hidden" name="TxType" value="PAYMENT" />
<input type="hidden" name="Vendor" value="<?= $Vendor ?>" />
<input type="hidden" name="VendorTxCode" value="<?= $VendorTxCode ?>" />
<input type="hidden" name="Currency" value="EUR" />
<input type="hidden" name="Amount" value="<?= $Amount ?>" />
<input type="hidden" name="NotificationURL" value="<?= $SuccessURL ?>" />
<input type="hidden" name="Description" value="<?= $Description ?>" />
<input type="hidden" name="BillingSurname" value="<?= $BillingSurname ?>" />
<input type="hidden" name="BillingFirstnames" value="<?= $BillingFirstnames ?>" />
<input type="hidden" name="BillingAddress1" value="<?= $BillingAddress1 ?>" />
<input type="hidden" name="BillingCity" value="<?= $BillingCity ?>" />
<input type="hidden" name="BillingPostCode" value="<?= $BillingPostCode ?>" />
<input type="hidden" name="BillingCountry" value="<?= $BillingCountry ?>" />
<input type="hidden" name="DeliverySurname" value="<?= $BillingSurname ?>" />
<input type="hidden" name="DeliveryFirstnames" value="<?= $BillingFirstnames ?>" />
<input type="hidden" name="DeliveryAddress1" value="<?= $BillingAddress1 ?>" />
<input type="hidden" name="DeliveryCity" value="<?= $BillingCity ?>" />
<input type="hidden" name="DeliveryPostCode" value="<?= $BillingPostCode ?>" />
<input type="hidden" name="DeliveryCountry" value="<?= $BillingCountry ?>" />
<input type="hidden" name="Crypt" value="<?= $PAYMENT_CRYPT ?>" />    
<input type="image" src="images/buynow-sagepay.png" />
<input type="submit" value="PAGAR" />
</form>

and this is my "credit-cards.php":

<?php
if(isset($_POST)){$data = $_POST;}

$url = curl_init("http://test.sagepay.com/gateway/service/vspserver-register.vsp");

$curlSession = curl_init();        
curl_setopt ($curlSession, CURLOPT_URL, $url);
curl_setopt ($curlSession, CURLOPT_HEADER, 0);
curl_setopt ($curlSession, CURLOPT_POST, 1);
curl_setopt ($curlSession, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 2);        
$result = explode(chr(10), curl_exec($curlSession));
?>

<html>
    <head>
    </head>
    <body>
        <br/>Escoje método de pago: <br/>
        <iframe src="<?= $_POST['NextURL'] ?>" id="sageFrame" style="width:100%;height:500px;border:none"></iframe>
    </body>
</html>

I finally use explode() in $result and I "cooked" my $nextURL correctly.

doing this, the iframe charges what i needed.

Thank you

    $return = array();
    foreach ($result as $string) {
      if (strpos($string, '=') != false) {
        $parts = explode('=', $string, 2);
        $return[trim($parts[0])] = trim($parts[1]);
      }
    }

use $return['NextURL']