Forum Moderators: coopster
i know i can pass a variable with POST or GET.
but i want to do the following:
a user enters wrong login credentials, so i redirect the user to error.php.
but i also want to pass the message "login credentials not found!".
I could do this with: header("location:index?php?page=error&err=wrong login credentials");
but i don't want the error string to be visible.
can i do this another way?
POST doesn't seem an option to me as there isn't a form involved.
grtz
Other ways of passing invisible data would be with a hidden form element.
It seems like there should be a php function that lets you send post data to a page like this:
post_to_url ($url, $data);
But I can't think of anything off the top of my head. Anyone?
// Prepare string to be sent as POST data
// Add the values into array $pData
// The formatted post string will be in the
// variable $pString
$pData = array();
$pString = '';
$pData['x_login'] = 'username';
$pData['x_password'] = 'password';
$pData['x_tran_key'] = 'keyvalue';
$pData['x_cardnum'] = '4111111111111111';
$pData['x_exp_date'] = '1108';
$pData['x_amount'] = '24.95';
foreach($pData as $key => $val)
$pString .= trim($key) . '=' . urlencode(trim($val)) . "&";
$pString = substr($pString,0,-1);
// Access remote site with the post data
// The resulting web page SOURCE CODE will be
// in the variable $aResult
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://secure.authorize.net/gateway/transact.dll");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $pString);
$aResult = curl_exec($ch);
curl_close($ch);