lalnfl Posted March 23, 2011 Share Posted March 23, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/ Share on other sites More sharing options...
Zane Posted March 23, 2011 Share Posted March 23, 2011 are you sure $req even exists? Did you declare it before you attempted to concatenate it? Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191523 Share on other sites More sharing options...
Pikachu2000 Posted March 23, 2011 Share Posted March 23, 2011 Why would you urlencode() the entire $_POST array? Are you sure you don't mean to use something else, like mysql_real_escape_string() perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191524 Share on other sites More sharing options...
lalnfl Posted March 23, 2011 Author Share Posted March 23, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191527 Share on other sites More sharing options...
Zane Posted March 23, 2011 Share Posted March 23, 2011 If it's $reg you want to put in the Content Length, then what is $req? Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191528 Share on other sites More sharing options...
Pikachu2000 Posted March 23, 2011 Share Posted March 23, 2011 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 ); Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191529 Share on other sites More sharing options...
lalnfl Posted March 23, 2011 Author Share Posted March 23, 2011 If it's $reg you want to put in the Content Length, then what is $req? lol, that was a mistake on here, not in my actual code. I mistyped it on here. Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191531 Share on other sites More sharing options...
lalnfl Posted March 23, 2011 Author Share Posted March 23, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191532 Share on other sites More sharing options...
lalnfl Posted March 23, 2011 Author Share Posted March 23, 2011 Seems as though I have fixed my own problem, as I am getting verifired from Paypal now. Awesome. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/231550-for-each-loop-and-_post-variables/#findComment-1191536 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.