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>"; ?> Quote Link to comment 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>"); Quote Link to comment Share on other sites More sharing options...
chandler Posted July 17, 2011 Author Share Posted July 17, 2011 Brill, works perfect many thanks Quote Link to comment 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.