Hi,
Does anyone know how to use the form to trigger a datetime stamp in a db field using a form field? I know I could set this up in MySQL, but I don't want to do it there. The records will be edited after the form is submitted. That particular date field may be updated by the, but we don't want the date to change while updating something else in the record.
Any help will be appreciated.
If you want the current datetime stamp, the variable is {date:format} where format is the mysql date format (eg Y-m-d H:i:s). So eg you put {date:Y-m-d H:i:s) as the value to save into the database.
I'm not exactly sure what you mean by your last sentence, the field will not be updated unless you specify it in Save Data. In the Save Data block, you can add "Data Source" under Advanced Settings. Add a new Data Source, set the Table field name and value, and on the right under Action, you can select "Insert". This means this field will only be updated when a new row is added in the database. If it is updating the row, the field will not be updated.
Hi Wbuk. Thank you again for your help. I truly appreciate it.
Now that I've read your post, I think there's something I missed with the creation of the form.
The form is a registration for a 1-year membership. The form as it currently is, only enters the 1st year's registration. So, for persons that are renewing their memberships, the form should find their records and update the information instead of creating new records. There's a field on the form to indicate if it is a renewal or not. This was added so that people who are already members and using the form for the 1st time, will be able to enter the database, which is fine for the first time. However, I'm going to spend tonight to make the form check if the user's email (unique) already exists in the db.
- IF there's no record with that email, then it will add a new record.
- IF the email already exists in a record, and the renewal field is checked, then it will update the records.
- IF the email already exists in a record, and the renewal field is NOT checked, then it will return the user to change the email or check the renewal field.
I'm going to work on this tonight. Thank's again for your help. I really appreciate it.
The other way to do it, is in your Save Data block, under Action, select "Insert, if duplicate Update".
IIRC for this to work, the "duplicate" has to be the database table's key. Usually, the id of the table is the key - so you'll need to change it so that the email is the key.