Jump to content

insert date/time from a webpage on my site into mysql


Recommended Posts

hi ok i know how to insert data into a mysql using forms and php scripts but i would like to insert date/time from a webpage on my site into mysql.

The date/time are auto generated and displayed on my webpage via a php scipt that is running on the webpage.


Is there a way to include the output of the date/time php script  in the  the rest of the form that follows it i.e so when users enter their name and a image and click upload the date/time will also be passed on to the php script that inserts the name/image into the mysql.


just to recap i have a webpage with a form where users enter their name/image and click uplaod and the values get passed to a php script that inserts the values into mysql but i would like the date/time that is being displayed on the same page to be passed on to the insert php script aswell.


i cant use the timestamp option in my mysql to auto generate the date/time as the server of mysql is in the usa and iam in the uk and so the date/time recorded is always wrong and as iam using a free host so i cant change the server time zone via .htaccess or php.ini or any other way till i upgrade and pay for hosting which i dnt want to do as  iam just learning at the moment.


below is the time.php script that generates and displays  the date/time on my website and also below is the simple form script on the same page.


hope some one can help.




$hourdiff = "14"; // hours difference between server time and local time

$timeadjust = ($hourdiff * 3600);

$melbdate = date("l, d F Y h:i a",time() + $timeadjust);

print ("$melbdate");






form script


<form method="post" enctype="multipart/form-data" action="file-upload.php">

  <div><?php echo $message; ?></div><?php echo $max_file_size_tag; ?>

Name: <input name="name" type="text"><br>

Please select file to upload: <input type="file" size="20" name="filename">

  <input type="submit" value="Upload" name="submit">


Link to comment
Share on other sites

ok i have tried doing that but can not figure out how i would include the date/time outputted by the php script into the hidden field before posting it along with the rest of form. xcuse my ignorance iam a newbie at this and yeah which forum should this be in anyway.



Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.