Jump to content

[SOLVED] Form Date


Lambneck

Recommended Posts

<?php

$handle = fopen('form_submissions.log');
$date = date(DATE_RFC822);
fwrite($handle, "form submitted on $date\n");
fclose($handle);

?>

 

Something like that would create a log and write dates to it.  I guess you could run something like this every time the form is submitted.

 

The file would like like this:

 

form submitted on Mon, 15 Aug 2005 15:12:46 UTC
form submitted on Mon, 16 Aug 2005 15:12:46 UTC
form submitted on Mon, 16 Aug 2005 15:12:46 UTC
form submitted on Mon, 17 Aug 2005 15:12:46 UTC
etc....

Link to comment
https://forums.phpfreaks.com/topic/104264-solved-form-date/#findComment-533766
Share on other sites

 

I just want to be able to

$_POST the date to a mysql database

but im new to php and dont know how.

 

 

 

On your form page......

 

form.htm

<form name = "my_form" action ="insert.php" method = "post">

<input type="hidden" name="date_submitted" value="<?php echo date("jS F Y")?>">

</form>

 

And on your insert to the db page......

 

insert.php

<?php
require('connect.inc');

$date_submitted = $_POST['date_submitted'];

$query = "INSERT INTO table (id,date_submitted) VALUES ('','$date_submitted')";
mysql_query($query);
?>

Link to comment
https://forums.phpfreaks.com/topic/104264-solved-form-date/#findComment-533862
Share on other sites

@realjumper: A user can change the timestamp then....just get the time on the PHP page.  The .5 seconds that it takes for the PHP page to load with the time won't destroy you.

 

Yes I suppose so, but it's very unlikely a user would do that because they won't be aware of the collection of the date of submission...unless they are looking at the code

Link to comment
https://forums.phpfreaks.com/topic/104264-solved-form-date/#findComment-533874
Share on other sites

I appreciate all the help  :D

 

I tried the following with no luck.

i just want the date of the form entry to be collected

when the form is submitted.

 

if (isset($_POST['Submit'])) 
{

$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$submission_date = datetime();

mysql_query("INSERT INTO $table (col_2, col_3, col_4, col_5, submission_date) VALUES ('$name', '$email', '$subject', '$message', '$submission_date')")or die(mysql_error());

    $user = $_POST['name'];

    echo '<table id=table1><tr><td><b><font size=2>Thank you ' . $user . ', your information was was submitted.</font></b></tr></td>';


}
?>

Link to comment
https://forums.phpfreaks.com/topic/104264-solved-form-date/#findComment-533933
Share on other sites

I used:

 

if (isset($_POST['Submit'])) 
{

$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$submission_date = date("jS F Y");

mysql_query("INSERT INTO $table (col_2, col_3, col_4, col_5, submission_date) VALUES ('$name', '$email', '$subject', '$message', '$submission_date')")or die(mysql_error());

 

and it displays "0000-00-00" in the database

 

how can I make it display something like this "Sun, 14 Aug 2005 16:13:03"  ???

 

 

Link to comment
https://forums.phpfreaks.com/topic/104264-solved-form-date/#findComment-533999
Share on other sites

I used:

 

if (isset($_POST['Submit'])) 
{

$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$submission_date = date("jS F Y");

mysql_query("INSERT INTO $table (col_2, col_3, col_4, col_5, submission_date) VALUES ('$name', '$email', '$subject', '$message', '$submission_date')")or die(mysql_error());

 

and it displays "0000-00-00" in the database

 

how can I make it display something like this "Sun, 14 Aug 2005 16:13:03"  ???

 

 

 

What 'type' is your submission_date field?.....int, varchar etc etc????

 

Here is a link to the PHP date & time formats http://www.wdvl.com/Authoring/Languages/PHP/Date_Time/

Link to comment
https://forums.phpfreaks.com/topic/104264-solved-form-date/#findComment-534005
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.