FORMfields, the premiere web framework
Login
Support Home | Knowledge Base | Documentation | Forums | Contact Us
Info
FORMfields & FORMgen :: Generated Forms

Displaying The Database ID Value in the Form Email

(1924 views. Last Updated: 2007-08-15 3:03 PM)

Here is an example ow how to display the id of the database record in the email sent after a form is submitted.

This is done by switching the order of the insert and sending of the email and retrieving the ID using a MySQL statement. Edit your form and replace:
// Send a second email?
if (FF_SEND_FORM_EMAIL2) 
{
    ...
}

if (FF_INSERT_INTO_DB) {
    $ffForm->addField(new DateTimeField("ff_inserted_on", "Inserted On", FORM_FIELD_REQUIRED, null));
    $ffForm->formFields["ff_inserted_on"]->getCurrentDateTime();
    $ffForm->insertValuesIntoDb(FF_FORM_NAME);
}
with:

if (FF_INSERT_INTO_DB) {
    $ffForm->addField(new DateTimeField("ff_inserted_on", "Inserted On", FORM_FIELD_REQUIRED, null));
    $ffForm->formFields["ff_inserted_on"]->getCurrentDateTime();
    $ffForm->insertValuesIntoDb(FF_FORM_NAME);
    $ffForm->addField(new FormField("ff_id", "ID"));
    $ffDb = &FfDb::s();
    $ffForm->setValue("ff_id", $ffDb->getSimpleValue("SELECT LAST_INSERT_ID()"));
}

// Send a second email?
if (FF_SEND_FORM_EMAIL2) 
{
    ...
}
Info
Support | Earn Money
Copyright © 2005-2019 Brain Book Software LLC.
Built with FORMfields, the premiere web framework.