googlit Posted November 10, 2012 Share Posted November 10, 2012 Hi, i am wanting to create a simple page with two buttons on, one that says 'start visit', one that says 'end visit', thats the simple bit, here's what i would like the form to do When 'Start Visit' is clicked i would like it to place an entry in the following db: I would like it to add the value "start visit" into the value field, automatically insert todays date into the date field and autonatically insert the time (GMT) into the time field. i have made general form before but have no idea on where to start....... any help would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/270542-newbie-question-about-submit-button/ Share on other sites More sharing options...
MDCode Posted November 10, 2012 Share Posted November 10, 2012 (edited) You need to use a form for each button because either will work if they are in the same form. When start visit is pressed just use sql. $sql = "INSERT INTO `table` (value,date,time) VALUES ('start visit', 'CURDATE()', 'date(h:i:s)')"; Edited November 10, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270542-newbie-question-about-submit-button/#findComment-1391561 Share on other sites More sharing options...
Pikachu2000 Posted November 10, 2012 Share Posted November 10, 2012 You can have multiple submit buttons in a set of form tags. Just give them different value= attributes. Quote Link to comment https://forums.phpfreaks.com/topic/270542-newbie-question-about-submit-button/#findComment-1391562 Share on other sites More sharing options...
Barand Posted November 10, 2012 Share Posted November 10, 2012 (edited) Define the time column as time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP This will insert the current date and time automatically when a new record is added. As this includes the date the separate date field is redundant. Edited November 10, 2012 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/270542-newbie-question-about-submit-button/#findComment-1391564 Share on other sites More sharing options...
googlit Posted November 10, 2012 Author Share Posted November 10, 2012 Thanks for your help.... problem solved. God i love this forum.... well of to hopefully help some others Quote Link to comment https://forums.phpfreaks.com/topic/270542-newbie-question-about-submit-button/#findComment-1391574 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.