zoobie
07-16-2003, 07:12 AM
I'm just about finished but my if/else statements below in bold need a little help...else if...somethin' like that. TIA
<?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.";
}
}
fclose ($fp);
}
?>
<?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.";
}
}
fclose ($fp);
}
?>