Hi, my first post, so here goes.
I am building a simple contact form using PHPFF. I have done these before without problems. What I now need to do is generate a unique reference number when the form is submitted.
From what I’ve read I think this could be done using the Form set-up menu and hidden fields perhaps? I can’t work out how to do it though.
I think I need to add the “$rma = uniqid();” code but don’t know how or ehere to put it exactly.
I know that the PHP easiforms suite can do it, but I’d rather try a simple solution first than have to pay $30!
In your Page / Form Setup dialog, locate the hidden fields control area. Click on New, and enter rma as the name. In the Value, enter the following exactly:
<?php echo uniqid(); ?>
That’s all there is to it. As long as you e-mail this to the customer and the home office at the same time (I believe PFF does that) both parties will have the same code.
Each time the form page is requested from the server, a different random 13-character code will be created. Unless your site is so busy that it is hosted from a cluster of servers, and they all had the misfortune to be started at the exact same microsecond in time, the odds of a collision in these numbers is incredibly slight.
Walter
On Jan 12, 2012, at 10:43 AM, JMC wrote:
Hi, my first post, so here goes.
I am building a simple contact form using PHPFF. I have done these before without problems. What I now need to do is generate a unique reference number when the form is submitted.
From what I’ve read I think this could be done using the Form set-up menu and hidden fields perhaps? I can’t work out how to do it though.
I think I need to add the “$rma = uniqid();” code but don’t know how or ehere to put it exactly.
I know that the PHP easiforms suite can do it, but I’d rather try a simple solution first than have to pay $30!
Thank you for your reply. I have been busy trying to work out the syntax of adding the code etc. This is really making me understand better the php elements of form making.
However, I still can’t get it to work!
I have added a hidden field in the form set-up named rma with the value of:
<?php echo uniqid(); ?>
How do I reference this number in the PHPFF email subject field?
I just looked at a “vanilla” PFF form handler, and it doesn’t look possible. The rma value isn’t interpreted until after the $subject line is defined in the handler, so there’s no way to sneak a variable value into it. You’re either going to have to write your own handler, or stick with the way that PFF handles hidden fields. (The rma value will be in the body of the message, but it can’t be in the subject as well.)
Tim could rewrite the Action to support variable subjects or a template language in these fields, but it’s not a simple thing and you’d have to ask him about his schedule.
Walter
On Jan 13, 2012, at 7:08 AM, JMC wrote:
Thank you for your reply. I have been busy trying to work out the syntax of adding the code etc. This is really making me understand better the php elements of form making.
However, I still can’t get it to work!
I have added a hidden field in the form set-up named rma with the value of:
<?php echo uniqid(); ?>
How do I reference this number in the PHPFF email subject field?
Thank you, Walter, for your help. Your time is very much appreciated. I did indeed have to change the php coding in the handler as you suggested and it did (eventually!) work. My client changed the requirement from a random number to an incremental number, so I used coding for a website visitor counter and embedded it into the php handler for my contact form.
So, compbined with the PFF, it all works smoothly; I’m a happy bunny and know a lot more about coding than a few days ago.
Thank you, Walter, for your help. Your time is very much appreciated. I did indeed have to change the php coding in the handler as you suggested and it did (eventually!) work. My client changed the requirement from a random number to an incremental number, so I used coding for a website visitor counter and embedded it into the php handler for my contact form.
So, compbined with the PFF, it all works smoothly; I’m a happy bunny and know a lot more about coding than a few days ago.