473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

cURL Question


Hi all,

Im a bit thrown by curl. I want to submit some order data on an ecommerce
site via a form to a php page, where the data is saved to a database.
Then I want to use curl to submit the form data I just saved (and
redirect the user) to my secure credit card gateway.

Problem is, they have their own secure payment screen where the credit
card information is entered. I can't just retrieve the variable with a
transaction success/failure setting. Plus, the curl code I use sends me
there as if I was still on my own server. No secure connection, and the
graphics on their server tries to load from mine. Looks very poor.

Anyway, here's the code:

$ch = curl_init("https://server.com/payment.url");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://site.com/payment.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_exec($ch);
curl_close($ch);
I guess my question is - is there an option in curl to acutally get the
browser to follow the posted data as if I clicked the button on a page?
FOLLOWLOCATION does not get me there for some reason.

All help is greatly appreciated!

DB
Jul 16 '05 #1
1 3326
Louis-Philippe Huberdeau <lp*********@sympatico.ca> wrote in
news:cD*******************@news20.bellglobal.com:
D Benfer wrote:
Hi all,

Im a bit thrown by curl. I want to submit some order data on an
ecommerce site via a form to a php page, where the data is saved to a
database. Then I want to use curl to submit the form data I just
saved (and redirect the user) to my secure credit card gateway.

Problem is, they have their own secure payment screen where the
credit card information is entered. I can't just retrieve the
variable with a transaction success/failure setting. Plus, the curl
code I use sends me there as if I was still on my own server. No
secure connection, and the graphics on their server tries to load
from mine. Looks very poor.

Anyway, here's the code:

$ch = curl_init("https://server.com/payment.url");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://site.com/payment.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_exec($ch);
curl_close($ch);
I guess my question is - is there an option in curl to acutally get
the browser to follow the posted data as if I clicked the button on a
page? FOLLOWLOCATION does not get me there for some reason.

All help is greatly appreciated!

DB


Well, you just skipped the secure part anyway. From the HTML form to
your script which should redirect the connection, your connexion
wasn't secure, the data was not safe. cURL will handle the secure
connection from the script to the other form processor, but your
connection won't be secured by that.

The best you can do is get the POST response by the secure server into
a string, analyse the result and display your own page. The default
behavior of cURL is to output the ressponse direcly, you can use
output buffering to solve that problem. (ob_start() and such).


Ah, ok. So the person who referred this to me was incorrect. I was told
this would _redirect_ you to a page. It just fetches the resulting page,
eh? No wonder I searched and searched and never found an answer! Thanks
for the response!

DB
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Haluk Durmus | last post by:
Hello I checked out openssl,mm,apr,apr-util,apache 2,curl,libxml and php from cvs. php couse an ERROR I did the following steps:
3
by: Hans | last post by:
Hi everybody, I am desperately trying to log into my account at godaddy.com with PHP and Curl and just cannot make it happen. Has anybody written a script for this purpose? Here is what I...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
4
by: zorro | last post by:
Hello there, I can't figure out why is it that when i use an array for my postfields it doesn't work : this works curl_setopt($curl, CURLOPT_POSTFIELDS, "clown=bozo" ); this doesn't...
0
by: existatus | last post by:
In a form there are entries like this: <input type="text" name="first_name" size="24" /> <input type="text" name="last_name" size="24" /> <input type="hidden" name="must_have" value="12345" />...
3
by: Mikhail Kovalev | last post by:
I'm sending a html form with cURL to some file.php which does something with the sent data and at the end redirects me to some other URL, which is different every time, something like this: $ch...
4
by: aritmico | last post by:
Hi all, I'm Bruno, an italian developer :) I' ve got a "little" problem since about 10 hours... I have a virtual server with PHP 5 and Apache 2 installed... Now I need to use the cURL lib...
7
by: h.stroph | last post by:
Greetings, I apologize for my lack of literacy with php, but am wondering if someone will tell me how to use the curl php functions to navigate to the page that results from entering the login...
11
by: Flexor | last post by:
I have a php script that runs from command line and makes an https request to paypal, using curl. It works fine if I run it from a web page. It fails if I run it from CLI. The error I get from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.