View Full Version : why are PayPal using things like & in a post?

03-01-2008, 10:39 AM
I'm having a time trying to get my head round this Paypal PDT php code.

the question I have is why are they using things like & in a post ($req .= "&tx=$tx_token&at=$auth_token";)

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];
$auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

03-01-2008, 10:58 AM
Simply passing parameters and their values through the query string. & is used to concatenate multiple parameters.

03-01-2008, 11:45 AM
Ah cool, also I see they didn't use $ to reference a parameter.

03-01-2008, 02:27 PM
Why would they?
The $variable would be set in their server side code.

Lee Stevens
03-01-2008, 05:42 PM
For that part of code i use:

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum