Jump to content

Recommended Posts

foreach ($_POST as $key => $value){

 

// Handle escape characters, which depends on setting of magic quotes

 

if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1){

 

$value = urlencode(stripslashes($value));

 

}

 

else {

 

$value = urlencode($value);

 

}

 

$req .= "&$key=$value";

 

}

 

$reg is not returning anything.

Link to comment
https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/
Share on other sites

Its for a Paypal Listener, and it says to encode it to send it back.

 

$req = "cmd=_notify-validate";

if (function_exists("get_magic_quotes_gpc")){

$get_magic_quotes_exists = true;

}

foreach ($_POST as $key => $value){

// Handle escape characters, which depends on setting of magic quotes 

if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1){
  		
	$value = urlencode(stripslashes($value)); 	

} 

else {

	$value = urlencode($value); 	

}

$req .= "&$key=$value"; 

}

$ch = curl_init("https://www.sandbox.paypal.com/cgi-bin/webscr");

curl_setopt($ch, CURLOPT_HEADER, "POST /cgi-bin/webscr HTTP/1.0\r\n");
curl_setopt($ch, CURLOPT_HEADER, "Content-Type: application/x-www-form-urlencoded\r\n");
curl_setopt($ch, CURLOPT_HEADER, "Content-Length: " . strlen($reg) . "\r\n\r\n");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$response = curl_exec($ch);

$http = curl_getinfo($ch, CURLINFO_HTTP_CODE); 

 

Also is the cURL right, in order to send it back to paypal?

OK, if that's what they say to do with it, I guess that's what they need . . .

Try this . . .

if( function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ) {
     $_POST = array_map( 'stripslashes', $_POST );
}
$_POST = array_map( 'urlencode', $_POST );

OK, if that's what they say to do with it, I guess that's what they need . . .

Try this . . .

if( function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ) {
     $_POST = array_map( 'stripslashes', $_POST );
}
$_POST = array_map( 'urlencode', $_POST );

 

Okay I got it to work. Is my cURL stuff right, when I send it back to paypal?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.