<?php
require_once("dbconnect.php");

$db_settings = new Database();

$db_settings-&gt;open();

$stack = array();

$p = new paypal_class;             // initiate an instance of the class

//$p-&gt;paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';   // testing paypal url

$p-&gt;paypal_url = 'https://www.paypal.com/cgi-bin/webscr';

$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

if ($p-&gt;validate_ipn())

{

$subject = 'Instant Payment Notification - Recieved Payment';

$to = $mail;    //  your email

$body =  "An instant payment notification was successfully recieved\n";

$body .= "from ".$p-&gt;ipn_data['payer_email']." on ".date('m/d/Y');

$body .= " at ".date('g:i A')."\n\nDetails:\n";

foreach ($p-&gt;ipn_data as $key =&gt; $value)

{

$body .= "\n$key: $value";

$stack[$key]=$value;

}

mail($to, $subject, $body);

unset($stack[merchant_return_link]);

//$invid = str_replace("OrderId#","", $stack['item_number']);

//database insert

$sdfsdfsdfsdnum = randomAlphaNum(16);

$updatecane_order="update  `cart` set mail ='".$stack['receiver_email']."',gen_no='".$sdfsdfsdfsdnum."', proprice       ='".$stack['payment_gross']."',     pay_act='Y' where cartid='".$stack['item_number']."'";

mysql_query($updatecane_order);

}
?.