chandler Posted July 17, 2011 Share Posted July 17, 2011 Can some one show me where I should put the date and time code into the comment script below, I want it to show the date and time in each comment that's made. like this echo date("l, F d, Y h:i" ,time()); I would like it in a div so I can add some css to it...thanks <?php if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $message = stripslashes($_POST['message']); $message2 = stripslashes($_POST['message2']); $fp = fopen('messages.txt', 'a'); fwrite($fp,"<div id=\"comments_box\"><div id=\"comment_name\"><p>$message <em>Says:</em></div><br />$message2</p></div>"); fclose($fp); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php echo "<div id=\"census41_messages\">"; readfile ('messages.txt'); echo "</div>"; ?> Link to comment https://forums.phpfreaks.com/topic/242192-help-with-where-to-put-code/ Share on other sites More sharing options...
JasonLewis Posted July 17, 2011 Share Posted July 17, 2011 Like this? fwrite($fp,"<div id=\"comments_box\"><div id=\"comment_name\"><p>$message <em>Says:</em></div><div id=\"comment_date\">Date: " . date("l, F d, Y h:i") . "</div><br />$message2</p></div>"); Link to comment https://forums.phpfreaks.com/topic/242192-help-with-where-to-put-code/#findComment-1243765 Share on other sites More sharing options...
chandler Posted July 17, 2011 Author Share Posted July 17, 2011 Brill, works perfect many thanks Link to comment https://forums.phpfreaks.com/topic/242192-help-with-where-to-put-code/#findComment-1243770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.