Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Wrapping Up The Project Sending The Contact Form Email

Jure Rožman
Jure Rožman
10,232 Points

PHP send mail

Hi. I was following guides in building simple PHP application, but I am just trying to use my form on my static html website, not a php website. I managed to send and receive email, but I get few error and I am not redirected to "index.html" as specified.

http://codepen.io/anon/pen/teouB - my code so far.

Here are errors I receive, but I still received email.

Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/adamsfitline/public_html/spider/inc/phpmailer/class.phpmailer.php on line 2387

Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/adamsfitline/public_html/spider/inc/phpmailer/class.phpmailer.php on line 2391

Warning: Cannot modify header information - headers already sent by (output started at /home/adamsfitline/public_html/spider/contact.php:38) in /home/adamsfitline/public_html/spider/contact.php on line 59

Thank you for your help, Jure R.

3 Answers

From what I can tell your file path for contents.html is wrong and hence why it cannot get the contents of the file. You have a bad characters in your regular expression function, preg_replace(), and you need to set your default timezone.

http://php.net/manual/en/function.date-default-timezone-set.php

Jure Rožman
Jure Rožman
10,232 Points

I removed those 2 lines so what is left to do is to set timezone + header problem. Thanks for a quick reply.

Logan R
Logan R
22,989 Points

For the header, try to move the PHP code to the top and comment out anything that will echo anything out before the header redirect and see if that removes the header error.