denoteone Posted March 3, 2008 Share Posted March 3, 2008 I am trying to understand if(!mail("mail function variables")) { echo "this is true or sucessfull}else{ echo "this failed"] is that how it works or is it check to see if it is false? I know this is a newbie question...but any help would be awesome. Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/ Share on other sites More sharing options...
revraz Posted March 3, 2008 Share Posted March 3, 2008 You have it backwards, you are checking !mail and echoing true. Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482355 Share on other sites More sharing options...
denoteone Posted March 3, 2008 Author Share Posted March 3, 2008 that makes sense then....thanks Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482359 Share on other sites More sharing options...
discomatt Posted March 3, 2008 Share Posted March 3, 2008 double post... delete sorry Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482362 Share on other sites More sharing options...
discomatt Posted March 3, 2008 Share Posted March 3, 2008 The ! before the function can pretty much be equated to == FALSE; so if (!function()) is the same as if (function() == FALSE) Be careful though... ! checks for both FALSE and 0.. so if your function returns a numeric value, and there's a chance it might be 0, be sure to use if (function() === FALSE) Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482365 Share on other sites More sharing options...
denoteone Posted March 3, 2008 Author Share Posted March 3, 2008 if(!mail('mrawers@******.com',$subject,$emailmessage,"FROM:$email",$headers)) {echo "error";}else{(html thank you page)} for some reason this keeps going into the error part of the if statement but I am getting the email message in my inbox? Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482376 Share on other sites More sharing options...
discomatt Posted March 3, 2008 Share Posted March 3, 2008 That's got me stumped. According to the php manual, the function returns as such Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482382 Share on other sites More sharing options...
kkeim Posted March 3, 2008 Share Posted March 3, 2008 try using brackets like : if(!(mail('mrawers@******.com',$subject,$emailmessage,"FROM:$email",$headers))) {echo "error";}else{(html thank you page)} Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482387 Share on other sites More sharing options...
revraz Posted March 3, 2008 Share Posted March 3, 2008 You should only pass 4 parameters, not 5. Combine your FROM: header into your $headers variable. Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482389 Share on other sites More sharing options...
denoteone Posted March 3, 2008 Author Share Posted March 3, 2008 $headers = "From: ".$email."\r\n"; $headers .= "Reply-To: mrawers@*******.com\r\n"; $headers .= "CC: sombodyelse@********.com\r\n"; $headers .= "Content-type: text/html\r\n"; is this how I set the from header with a variable? Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482430 Share on other sites More sharing options...
denoteone Posted March 3, 2008 Author Share Posted March 3, 2008 Got it! Thanks everyone for your help and feed back. Quote Link to comment https://forums.phpfreaks.com/topic/94172-check-if-true/#findComment-482446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.