Hi all,
I'm trying to attach an ID to each form submission. The ID needs to be formated like mmddyy-### (example: 061708-001). Any suggestion on how this can be achieved?
I think php echo from the db assigns to a hidden field that's date formatted could do the trick...
Thanks,
William
I'm trying to attach an ID to each form submission. The ID needs to be formated like mmddyy-### (example: 061708-001). Any suggestion on how this can be achieved?
I think php echo from the db assigns to a hidden field that's date formatted could do the trick...
Thanks,
William
Hi William,
If it needs to be a serial field than you are going to need some way to store the value. You could to this in a database table or a text file . . .
You probably don't want it in the form because not all forms will be submitted. All you need in the form is a hidden field as a place holder:
If it needs to be a serial field than you are going to need some way to store the value. You could to this in a database table or a text file . . .
You probably don't want it in the form because not all forms will be submitted. All you need in the form is a hidden field as a place holder:
<input type='hidden' name='id' value='' />
You can generate the id in the OnSubmit before box. and include it in both the email and the data saved to the database.<?php
$serial = //find last value
$_POST['id'] = date('dmy').$serial++;
// save $serial
?>
Bob
Hi Bob,
I tried inserting your code, but i'm quite lost on
What should that equal to?
My debug shows
I tried inserting your code, but i'm quite lost on
$serial =
What should that equal to?
My debug shows
[id] =>
Hi William,
Yup, you need to write some code to create/look-up your serial number.
Bob
Yup, you need to write some code to create/look-up your serial number.
Bob
Here's what I did for the code for the serial number: (added to On Submit code - before sending email)
<?php
$myFile = "requestnum.txt";
$handle = fopen($myFile, 'r');
$serial = fread($handle, 3);
fclose($handle);
$serial++;
$_POST['requestid'] = date('dmy').$serial;
$data = sprintf("%'03u", $serial) . "\n";
echo $data;
$Handle = fopen($myFile, 'w');
fwrite($Handle, $data);
fclose($Handle);
?>
Now in my email template I have:|{requestid}|{email}|{institution_name}|{institution_address}|
but when I receive the email the requestid is blank, why is that, what am I doing wrong?
Hi dwayne,
Add a hidden field to your form html so that ChronoForms knows to look for a requestid variable:
Add a hidden field to your form html so that ChronoForms knows to look for a requestid variable:
<input type="hidden" name="requestid" value="" />
Bob
I did add the hidden variable to the form and it comes up blank in the email. Any other ideas?
This topic is locked and no more replies can be posted.