Error messages:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /homepages/4/d142124103/htdocs/header.htm:5) in /homepages/4/d142124103/htdocs/end2.php on line 15
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /homepages/4/d142124103/htdocs/header.htm:5) in /homepages/4/d142124103/htdocs/end2.php on line 15
Notice: Undefined variable: header in /homepages/4/d142124103/htdocs/end2.php on line 18
Notice: Undefined offset: 1 in /homepages/4/d142124103/htdocs/end2.php on line 51
code I am using (from paypal):
<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "uidZRxXdq-hJW2BG57wfPN1dZgrKS2yZV-CRUIFsjnThHr4sBhmzUloKC88";
$req .= "&tx=$tx_token&at=$auth_token";
include_once ('header.htm');
error_reporting(E_ALL);
session_start();
// 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.sandbox.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.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$num_cart_items = intval($keyarray['num_cart_items']);
$amount = $keyarray['mc_gross'];
$cartData = array();
for ($i=1; $i <= $num_cart_items; $i++)
{
$_SESSION['quantity'.$i] = "". $keyarray["quantity".$i] . "";
//echo ("<tr><td><font face = \"Verdana\" size = \"2\">" . $keyarray["option_selection1_".$i] ."</font</td>");
//echo ("<td> </td>");
//echo ("<td><font face = \"Verdana\" size = \"2\">" . $keyarray["item_name".$i]. "</font></td>");
//echo ("<td> </td>");
//echo ("<td align=\"center\">". $keyarray["quantity".$i] ."</td>");
//echo ("<td> </td>");
$test1 = "". $keyarray["item_name".$i] . ".pdf";
if ($_SESSION["quantity".$i] > 0){
echo ("<td><font face = \"Verdana\" size = \"2\"><a href=\"testfile.php?arg1=$test1\">Click to download.</a></font></td>");
$_SESSION["quantity".$i]--;
//$test2 = $_SESSION["quantity".$i];
//echo("downloads left :$test2");
}
else{
echo ("<td>Download complete</td>");
}
}
echo ("<p align = \"center\"><font face = \"Verdana\" size = \"2\"><b>Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br>You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br></b></font></p>");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}
}
fclose ($fp);
include_once ('footer.htm');
?>