nick2price Posted June 29, 2010 Share Posted June 29, 2010 Sorry. Just a quick question. I have the following foreach($_SESSION as $k => $sess){ $message .= $k.": ".$sess."\n".$emailID."\n"; } if(mail($to, $subject, $message)){ header("Location: successfulPayment1.html"); } else { echo "ERROR!"; } } else { echo "ERROR!"; } Witout the mail function in an if statement, I received the session variables. With it in the if statement, I receive empty variables. Is the if statement interfering with the forelse loop? And is there a way I can do it like i am attempting, because I only want the header if the email was successful. Link to comment https://forums.phpfreaks.com/topic/206221-would-this-cause-a-problem/ Share on other sites More sharing options...
ChemicalBliss Posted June 30, 2010 Share Posted June 30, 2010 Is the if statement interfering with the forelse loop? No is there a way I can do it like i am attempting, because I only want the header if the email was successful. 1. There is no way to know if the email was recieved, only if it was managed to be sent. 2. The code you have provided here (minus the extra else statement at the bottom) is in working order. eg: foreach($_SESSION as $k => $sess){ $message .= $k.": ".$sess."\n".$emailID."\n"; } if(mail($to, $subject, $message)){ header("Location: successfulPayment1.html"); } else { echo "ERROR!"; } Should work as intended. (Assuming $emailID is already set before this code, and that Sessions variables do exist.) -cb- Link to comment https://forums.phpfreaks.com/topic/206221-would-this-cause-a-problem/#findComment-1078987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.