sandrine Posted May 19, 2009 Share Posted May 19, 2009 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. <?php $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"> </form> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 There are the DATE_ADD and ADDTIME functions for MySQL. They would probably work better. But you can add a hidden field if you must do it your way. One more thing - please post in the correct forum next time. Quote Link to comment Share on other sites More sharing options...
sandrine Posted May 19, 2009 Author Share Posted May 19, 2009 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. thanx Quote Link to comment Share on other sites More sharing options...
BK87 Posted May 20, 2009 Share Posted May 20, 2009 <input type="hidden" name="time" value="<?= $melbdate; ?>"> 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.