keaauBoy Posted September 30, 2015 Share Posted September 30, 2015 Several members of this forum recently helped me with a problem with my web host and i thank you. I have xampp on my machine and while testing my php pages everything works perfectly including my thank you page. However when I upload the pages to the server all the fields works correctly and even the error message for the email format runs but when I hit the submit button the form simply returns to its initial state where all fields are blank and the neither the warning...'Sorry your mail could not be sent' or the thank you page appear. I'm not sure if I have the correct code for the authenticate staement. Could someone help me with this problem.formTest.php mail_process.php thanks.php Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/ Share on other sites More sharing options...
scootstah Posted September 30, 2015 Share Posted September 30, 2015 You have a bunch of conditionals that could fail, but you're not handling that failure. My guess is that $mailSent is false. You also have a syntax error here: if(!mailSent) { $errors['mailfail'] = true; }Make sure you are developing with all errors turned on to prevent things like that. Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1521990 Share on other sites More sharing options...
keaauBoy Posted October 1, 2015 Author Share Posted October 1, 2015 I'm not sure why there is a syntax error in the above code. I'm a total newbie, a Photoshop and After Effects guy who does know some JavaScript and HTML but not php and I'm trying to do a website for great old 93 year old man.. When you say my conditionals could fail but I am not handling that I'm stumped. Also how do I turn errors on. I know its probably a really easy question but I don't know where to find the answer. Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522039 Share on other sites More sharing options...
scootstah Posted October 1, 2015 Share Posted October 1, 2015 I'm not sure why there is a syntax error in the above code. Hint: Variables must start with a $ When you say my conditionals could fail but I am not handling that I'm stumped. Well, in a lot of places you're only handling the "true" part of the conditional. If it is "false", your script will just silently do nothing. Also how do I turn errors on Edit your php.ini and: - set "error_reporting" to "-1" - set "display_errors" to "On" Make sure to restart Apache afterwards. Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522040 Share on other sites More sharing options...
keaauBoy Posted October 1, 2015 Author Share Posted October 1, 2015 my error_reporting settings in php.ini are ; error_reporting; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED; Development Value: E_ALL; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT How do I set that to -1 Set display_errors to 'on' Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522045 Share on other sites More sharing options...
keaauBoy Posted October 1, 2015 Author Share Posted October 1, 2015 I corrected the variable 'if(!$mailSent){ } and now I at least get the error message 'Sorry your mail could not be sent' things are looking up but its still not sending, more hints please Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522046 Share on other sites More sharing options...
hansford Posted October 1, 2015 Share Posted October 1, 2015 Should look something like the following. display_errors = On ; Default Value: On ; Development Value: On ; Production Value: Off Optionally, at the top of each php page you can set error handling with the following: error_reporting(E_ALL); ini_set('display_errors', 1); Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522047 Share on other sites More sharing options...
scootstah Posted October 1, 2015 Share Posted October 1, 2015 (edited) my error_reporting settings in php.ini are ; error_reporting ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT How do I set that to -1 Remove the semicolon in front of error_reporting and set its value to -1. error_reporting = -1 ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICTDo the same with display_errors (except its value will be set to On). but its still not sending, more hints please So then the call to mail() is failing and returning false. This is possibly due to a server configuration problem. You can attempt to display the last error message and see if it gives any helpful clues. if(!$mailSent) { echo '<pre>' . print_r(error_get_last(), true) . '</pre>'; exit; $errors['mailfail'] = true; }This is just a temporary quick bodge for debugging purposes. After you figure out the problem you can remove those two new lines. If you get any output from that please include it with your next reply. Edited October 1, 2015 by scootstah Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522084 Share on other sites More sharing options...
keaauBoy Posted October 1, 2015 Author Share Posted October 1, 2015 After all the changes were made, the first time I hit the submit button I got the thank you page. See attached I ran it again and didn't get the thank you page, but did get the formTest.php with nothing on it. The form and the fields were blank but browser still had formTest.php in the url window. Client reports no email received Quote Link to comment https://forums.phpfreaks.com/topic/298381-php-form-to-email-wont-send/#findComment-1522102 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.