I've just about finished this short script but a few of my if/else statements need help. Could someone take a look? They're in bold near the bottom. Thanks a mil.
<?php
$my_email = 'my-primary-email@home.com';
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// 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);
// assign posted variables to local variables
$item_name = $POST['item_name'];
$item_number = $POST['item_number'];
$payment_status = $POST['payment_status'];
$payment_gross = $POST['payment_gross'];
$txn_id = $POST['txn_id'];
$receiver_email = $POST['receiver_email'];
if (!$fp) {
echo "<html><body bgcolor='#ffffff'><br><br><div align='center'>SERVER ERROR - Try again later</div></body></html>";
}
else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
if (strcmp($receiver_email,$my_email) == 0) {
echo "ERROR 904 - Receiver email mismatch";
}
if (strcmp('Completed',$payment_status) == 0) {
echo "ERROR 707 - Payment not completed";
}
if (strcmp('0.03',$payment_gross) == 0) {
echo "ERROR 803 - Price has been changed";
}
//if everything has passed, go ahead and show the echo below
else
echo "<html><body style='background-color:black;overflow:auto'><br><br><div align='center'><form name='fred' action='mail.php' method='post'><button style='border:1px solid white;width:200px;height:35px;background-color:black;font:bold 20px tahoma;color:lime;cursor:pointer' onclick='this.fred.submit();'>SEND IT!</button></form></div></body></html>";
}
else if (strcmp ($res, "INVALID") == 0) {
echo "ERROR 007 - There is something wrong with your Paypal account.<br>Payment denied, failed, pending, or unconfirmed.";
}
}[/b]
fclose ($fp);
}
?>