kayz100 Posted December 9, 2013 Share Posted December 9, 2013 I can't seem to see the problem with my success and not success form below. The form is sent successfully but keep outputting oops try again <?php if ($success) { $message = "Message sent succesfully! Thank you."; } else { $message = "Oops! Try again!"; } echo '<div id="message">'.$message.'<div id="close-button"></div></div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/284644-form-success-filure/ Share on other sites More sharing options...
paddy_fields Posted December 9, 2013 Share Posted December 9, 2013 You have no condition in the IF statement. $success needs to have a value, so for your example when the form is submitted by the user sucessfully set $success to be 'YES'. And then include that in the IF statement. <?php if ($success=='YES') { $message = "Message sent succesfully! Thank you."; } else { $message = "Oops! Try again!"; } echo '<div id="message">'.$message.'<div id="close-button"></div></div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/284644-form-success-filure/#findComment-1461750 Share on other sites More sharing options...
paddy_fields Posted December 9, 2013 Share Posted December 9, 2013 Actually, what am I saying... you can have an IF statement without a conditon. As long as $success is true, then that will work. So... you need to make sure you set $success after the form has been sent... $success = true; debug by printing the contents of $success at the end of your current code and see what is actuall in there Quote Link to comment https://forums.phpfreaks.com/topic/284644-form-success-filure/#findComment-1461800 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.