Jump to content

Recommended Posts

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:

 

scsht1.jpg

 

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

Link to comment
https://forums.phpfreaks.com/topic/270542-newbie-question-about-submit-button/
Share on other sites

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 by SocialCloud

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 by Barand
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

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