Hi, I've a kind of cms system where I am calling a function to pass post data and redirect to a specific url, well it works only if i echo the curl_exec result and it automatically appends the whole results page.. which is not supposed to do.
Note the browser url is not changed too.
here is the small class wrapper and the piece of code executing it..
I'm on this matter for 2 days still cant re resolve..
Thanks in advance
here is the small class wrapping for curl
<?php
/**
* CURL
* Function to send POST data via HTTPS/HTTP
* Requires PHP cURL Extension to be enabled at the server
* @version $Id$
* @access public
*/
class CURL {
var $callback = true;
function setCallback($func_name) {
$this->callback = $func_name;
}
function doRequest($method, $url, $vars) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
if ($this->callback)
{
$callback = $this->callback;
$this->callback = false;
return call_user_func($callback, $data);
} else {
return $data;
}
} else {
return curl_error($ch);
}
}
function get($url) {
return $this->doRequest('GET', $url, 'NULL');
}
function post($url, $vars) {
return $this->doRequest('POST', $url, $vars);
}
}
?>
now here is the function code to execute it
function cart_orders_db_submitPayment(){
include_once('curl.class.php');
// todo - fix the session variable names
$data = "bill_name=".$_SESSION['RP_USR']['USER_TAG'].
"&bill_email=".$_SESSION['RP_USR']['USER_EMAIL'].
"&orderid=".$_SESSION['RP_CART']['ORDERID'].
"&amount=".$_SESSION['RP_CART']['TOTALCOST'].
"&country=MY".
"&bill_desc=".rp_getServerConstant('default_description');
//$Curl_Session = curl_init('https://www.onlinepayment.com.my/NBepay/pay/redribbondays/?');
//curl_setopt ($Curl_Session, CURLOPT_POST, 1);
//curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, $data);
//curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 0);
//$processing = curl_exec ($Curl_Session);
//curl_close ($Curl_Session);
$newReq = new CURL();
$processing = $newReq->post('https://www.securepayment.com/pay/rrd1/?',$data);
echo $processing;
}
:eek: