/    Sign up×
Community /Pin to ProfileBookmark

adding date, time

Hello all. When I get a message i would like to see the day, month, year, and time when it was sent. Please help, I know html well, but my php sucks! Thanks!

[B]HERES MY HTML CODE[/B]

[CODE]<form name=”contactform” action=”contactform.php” method=”post”>
<table>
<tr>
<td height=”335″ width=”1020″ style=”text-decoration:none; font-size:75%; text-align:center”>IF YOU HAVE A QUESTION OR COMMENT PLEASE CONTACT US AT:<br />INFO&#64;BLAH.COM<br /><br />YOU MAY ALSO CONTACT US THROUGH OUR FORM:<br /><br />
NAME:<input type=”text” size=”46″ name=”name” class=”text1″ style=”font-family:times” />
<br />
EMAIL:<input type=”text” size=”46″ name=”email” class=”text2″ style=”font-family:times” />
<br />
<br />
<textarea name=”text” rows=”5″ cols=”58″ style=”font-family:times”>
</textarea>
<br />
<br />
<a onclick=”document.contactform.reset();return false;” href=”#”><img alt=”Reset” src=”reset.gif” border=”0″ /></a>&nbsp;/
<input type=”image” src=”submit.gif” alt=”Submit” onclick=”javascript:alert(‘Thank you! We will get back to you shortly!’)” /></td>
</tr>
</table>
</form>[/CODE]

[B]HERE IS MY PHP CODE[/B]

[CODE]<?php
$name = $_POST[‘name’];
$email = $_POST[’email’];
$text = $_POST[‘text’];

mysql_connect (“blah”, “blah”, “blah”) or die (‘Error: ‘ . mysql_error());
mysql_select_db (“blah”);

$query=”INSERT INTO contacttable (name, email, text)VALUES (‘$name’,’$email’,’$text’)”;

mysql_query($query) or die (‘error updating database’ . mysql_error());

header(‘location: contact.html’);
exit;

?>[/CODE]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bejitto101Nov 16.2008 — Well, you can create a field in the table with the the type TIMESTAMP, then for attribute: ON UPDATE CURRENT_TIMESTAMP.

Or you could just make a regular extra field and use create the date with something like this:

[code=php]
$today = date("F j, Y, g:i a"); // Format: March 10, 2001, 5:16 pm

$query="INSERT INTO contacttable (name, email, text, date)VALUES ('$name','$email','$text','$today')";
[/code]


It uses PHP's date function: http://us2.php.net/date
Copy linkTweet thisAlerts:
@ADLEauthorNov 16.2008 — Ah that worked well, thank you so much!
×

Success!

Help @ADLE spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...