route609 Posted February 5, 2008 Share Posted February 5, 2008 Hello This is my very first post as i am just begining to learn php. I have created/copied a contact form and implemented it into my website. Everything works fine apart from one thing, when i recieve the email from the contact form the time on the email is 5hours faster than the time the email was sent. The code i have is this: $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n "; How do i set the time/date to make sure the correct time and date show on the email from when the contact form was sent? Thank you Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/ Share on other sites More sharing options...
beansandsausages Posted February 5, 2008 Share Posted February 5, 2008 if your inserting the info in to a db as well just use the NOW() function, if not i cant help you sorry Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/#findComment-458550 Share on other sites More sharing options...
route609 Posted February 5, 2008 Author Share Posted February 5, 2008 if your inserting the info in to a db as well just use the NOW() function, if not i cant help you sorry Hi I dont think i am instering into a database. Liek i said i took the form from the net and modifed parts, so all i have is the sendemail.php and contact.php. Thanks anyway, Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/#findComment-458561 Share on other sites More sharing options...
PFMaBiSmAd Posted February 5, 2008 Share Posted February 5, 2008 You would need to post your code that is getting and placing the time into the message to get the quickest solution. If you are using the date() function, then use the date_default_timezone_set() function (php5) to set the time zone that the code uses. Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/#findComment-458564 Share on other sites More sharing options...
route609 Posted February 5, 2008 Author Share Posted February 5, 2008 You would need to post your code that is getting and placing the time into the message to get the quickest solution. If you are using the date() function, then use the date_default_timezone_set() function (php5) to set the time zone that the code uses. Thank you, thats great, How do i do it? I am totally new to PHP. would i change the $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n "; script? If so what would i put instead Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/#findComment-458569 Share on other sites More sharing options...
beansandsausages Posted February 5, 2008 Share Posted February 5, 2008 please post all your code for the three files. Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/#findComment-458625 Share on other sites More sharing options...
route609 Posted February 5, 2008 Author Share Posted February 5, 2008 please post all your code for the three files. Hi sendemail.php file source: <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use Back - [email protected]</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "Not all fields have been completed correctly<br />\n"; die ("Please use the back button at the top of the browser"); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n "; $from = "From: $visitormail\r\n"; mail("[email protected]", $subject, $message, $from); ?> <p align="center"> <strong>Thank You :</strong> <br /> <?php echo $visitor ?><br /> ( <?php echo $visitormail ?> ) <br /><br /> <strong>Message:</strong> <br /> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?> Contact.php source code file : <form method="post" action="sendemail.php"> <!-- DO NOT change ANY of the php sections --> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> Full Name: <br /> <input type="text" name="visitor" size="35" id="textfield" /> <br /><br /> E-mail:<br /> <input type="text" name="visitormail" size="35" id="textfield2" /> <br /> <br /> Attention:<br /> <select name="attn" size="1" id="textfield3"> <option value=" Partners ">Partners </option> <option value=" Projects ">Projects </option> <option value=" Proposal ">Proposal </option> <option value=" Other ">Other </option> </select><br /><br /> Query: <br /> <textarea name="notes" rows="4" cols="40" id="textarea"></textarea> <br /><br /> <input type="submit" value="Submit" id="button" /> </form> These are the only two files i have for this, Thank you ! Link to comment https://forums.phpfreaks.com/topic/89522-how-to-change-todayis-est-time-on-php-form/#findComment-458653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.