cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

RE: Trouble Updating URL On Post

From: Justin <justin_at_sacloaves.org>
Date: Mon, 7 Apr 2008 14:06:10 -0700

Thanks for your suggestions. I looked into the header(location) but it still
didn't get me what I needed. I looked a little deeper, and asked a friend
who knows curl and he pointed out that I could receive the response from a
CURLOPT_POST using the CURLOPT_RETURNTRANSFER, true.

So I'm using this:

$RETURNVAL = curl_exec ($curl);

To receive the url response and save it in $RETURNVAL as a string. Now I
just have to figure out how to parse the data. So I can use it.

-Justin

-----Original Message-----
From: YupLounge website analyse en optimalisatie [mailto:info_at_yuplounge.com]

Sent: Wednesday, April 02, 2008 12:12 AM
To: justin_at_sacloaves.org; 'curl with PHP'
Subject: RE: Trouble Updating URL On Post

Hello Justin,

Curl does not open a new screen. It collects the data from the approved or
declined file. That's the reason why you still see the old URL. It does
publish however the contents of the files in that screen.
If you want to update your screen than you have to make a
 header('Location: http://www.example.com/');
of course you've got to clean the Get-variables first with
$_GET = array();

Looking at your code an even better solution is to let ProcesReturn save the
CreditCard return information in a database. It will than be a background
process and your user won't even see it.
Publishing the information can be done in several ways. For instance a
combination of php (collection for user X the credit card return info) and
Ajax (every x seconds do a database check) Or you only use PHP for
collecting and let the customer click on an status-recheck button.

Succes

Willem-Peter

-----Oorspronkelijk bericht-----
Van: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] Namens Justin
Verzonden: woensdag 2 april 2008 0:31
Aan: curl-and-php_at_cool.haxx.se
Onderwerp: Trouble Updating URL On Post

Hello there,

I'm rather new to cURL and php, but I've been having a great time learning
and figuring things out. However, I've run into a problem that I haven't
been able to solve. Any help would be greatly appreciated. Here is the jist:

I'm receiving some variables from an external server (a credit card
processor) and they send their variables to me using a Get, or at least the
variables all show up in the URL. I want to take these variables and print
them on the screen for the user to see as a receipt, but I don't want all
the variables to be visible to them.

I thought in order to solve the problem I would create a
script(processreturn.php) that accepts the variables and then posts them to
another page(approved.php) so that the variables would not be visible in the
URL. The problem I'm having is that even after the POST the URL still stays
the same(still contains the variables) but the content of the page changes
to the new page? Any ideas on how to get the URL to update to the new
page(approved.php) and lose the variables in the URL?

Thanks in advance for any advice.

Here is my code:

ProcessReturn.php - This receives the information from the external server.

<?php

$ccnumber = $_GET['ssl_card_number'];
$amount = $_GET['ssl_amount'];
$expdate = $_GET['ssl_exp_date'];
$address = $_GET['ssl_avs_address'];
$city = $_GET['ssl_city'];
$state = $_GET['ssl_state'];
$zip = $_GET['ssl_avs_zip'];
$first = $_GET['ssl_first_name'];
$last = $_GET['ssl_last_name'];
$company = $_GET['ssl_company'];
$result = $_GET['ssl_result'];

if ($company=="approved") {
  $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL," /approved.php");
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS,

"ccnumber=$ccnumber&amount=$amount&frist=$first&last=$last&adress=$last&city
=$city&state=$state&zip=$zip&company=$company");
       
 

    curl_exec ($curl);
    curl_close ($curl);}

else {
  $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL," /declined.php");
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS,

"ccnumber=$ccnumber&amount=$amount&frist=$first&last=$last&adress=$last&city
=$city&state=$state&zip=$zip&company=$company");
    
    curl_exec ($curl);
    curl_close ($curl);}

?>

Approved.php - Here is where the POST goes if approved.
<?php

$ccnumber = $_POST['ccnumber'];
$cvc = $_POST['cvc'];
$amount = $_POST['amount'];
$expdate = $_POST['expdate'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$first = $_POST['first'];
$last = $_POST['last'];
$company = $_POST['company'];

?>
Your order has been approved. Please print the following transaction report
for your records.
<table border="0">
<tr><td><?php echo $first . " " . $last; ?></td></tr>
<tr><td><?php echo $company; ?></td></tr>
<tr><td><?php echo $ccnumber; ?></td></tr>
<tr><td><?php echo $amount; ?></td></tr>
<tr><td><?php echo $address; ?></td></tr>
<tr><td><?php echo $city; ?></td></tr>
<tr><td><?php echo $state; ?></td></tr>
<tr><td><?php echo $zip; ?></td></tr>
</table>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-04-07