PDA

View Full Version : Counter number on formmail messages



Solecon
30-Nov-2006, 11:13 PM
I just added the Tectite formmail to my site so that customers could send attachments through our server rather than risk them getting lost in spam filters. It works great so thank you.

I also use MSA formmail perl script but I modified it to add a counter number to the message. It does this by reading, incrementing, and writing a file containing the counter number. It then appends this counter number to the subject of the senders form response.

I don't see this being an option in the Tectite version of formmail although I haven't weeded through every single line of code in the script file.

Does this formmail support counters? If not, does someone have a recommendation on how to best do it? (there's a daunting amount of code I'd hate to screw up...)

Thanks,
Dan

russellr
30-Nov-2006, 11:35 PM
Hi,

Version 7.12 supports this.

I'll update the version on the website (Config Wizard and download) shortly.

To use the feature, you need to do this:
Configure the NEXT_NUM_FILE setting in FormMail.
Derive a field to contain the next number, like this:


<input type="hidden" name="derive_fields" value="Counter=%nextnum%" />

Solecon
08-Dec-2006, 07:35 PM
Thanks Russell,
That works quite nicely. But now I'm putting the "counter" into the subject line and have a new question. Can the formmail.ini file be used to store variables like sub_one in the following?



<INPUT TYPE=HIDDEN NAME="sub_one" VALUE="Form Input from Contact Page: #">
<input type="hidden" name="derive_fields" value="Tracking=%nextnum%,subject=sub_one.Tracking" />

doing this in the form creates an extra field called "sub_one" which gets reported in the email I receive from the form:


sub_one: Form Input from Contact Page: #

If I comment out the sub_one input and add:


[special_fields]
sub_one = "Form Input from Contact Page: #"

to the formmail.ini file my email subject just comes through with just the tracking number as the subject.

Since I'd rather not have to strip out the sub_one line in my email response to the form-filling customer, I'm interested in hiding it in the ini file like email addresses can be.

So what can and cannot be hidden in the formmail.ini file?

Thanks,
Dan

russellr
08-Dec-2006, 09:08 PM
Hi,

Currently, you can only put special fields and email addresses in the INI file.

I actually don't think it makes any sense to allow non-special fields in the INI file: if they are not special, why can't they go in the HTML form?

If I can be convinced of the value of allowing general fields in the INI file, I'll obviously implement it, but we'll have to wait and see. Even so, any non-special field created in the INI would still be included in the email (all non-special fields are, but see below).

Your "sub_one" is not a special field, which is why what you're doing (defining it in the INI file) has no effect.

Why not use a literal in your derive_fields instead of creating "sub_one"?

Alternatively, keep "sub_one" as a hidden field in your HTML and simply exclude it with mail_options.

Solecon
08-Dec-2006, 09:47 PM
I think I've come up with a solution...

I'm trying using a template for the email. But now I can't get the sender's IP added to the message! If I ask for $env_report I get "REMOTE_ADDR" instead of the value for the REMOTE_ADDR.

But hey, the extra line with sub_one disappears if I don't ask for it in the template so win some lose some!

Dan

Solecon
08-Dec-2006, 10:15 PM
Why not use a literal in your derive_fields instead of creating "sub_one"?


I did try that but it didn't work. Maybe my syntax is wrong.


<input type="hidden" name="derive_fields" value="subject='Form Input from Contact Page: #'.%nextnum%" />

puts nextnum into the subject but not the preceeding text.

sigh...
Dan

russellr
08-Dec-2006, 11:55 PM
Hi,

That's close to being right.

Review the HOW TO guide on deriving fields for the correct syntax.

no1uno
12-Jan-2007, 03:52 PM
Hi

As I have no knowledge on PHP, I have been looking for a webform with specific functions for months. I have finally found FormMail :D

The one specific function I really need is the counter number as my form will be a order form.
Could I please get some help to set up this. I need it to do the following if possible:

* Create a unique number in either the "thankyou" page or the HTML email sent to the user
* The same number sent in the HTML email to me
* and if possible decide the start range of the number in the configuration file (formmail.php)

Any help on this would be greatly appreciated.

Thanks

russellr
12-Jan-2007, 07:15 PM
Hi,

I'm a bit confused. The answer to your counter number question is above where you posted on this thread. :confused:

If you want specific support for your requirements, please post in the Community Support forum or Subscribe for support.

no1uno
12-Jan-2007, 11:28 PM
Hi Russell

The conversation in this thread between yourself and Solecon is a lot of techicnal stuff that goes way over my head.
The only bit that I got was to

Configure the NEXT_NUM_FILE setting in FormMail.
Derive a field to contain the next number, like this:

<input type="hidden" name="derive_fields" value="Counter=%nextnum%" />


I did find the settings in FormMail which needed a path to a file, only problem is I don't know what file. I ended up just creating a text file titled, NEXT_NUM_FILE.txt, and uploaded it to the server.
The above code I inserted in my form just under


<input type="hidden" name="subject" value="Sample FormMail Testing" />

Now I get the following error sent to me in a email


The following error occurred in FormMail :
next_num_file *********
Error=Cannot open next number file 'E:/site2/public_html/forms': failed to open stream: Permission denied
I have given full write permissions to the text file but still same problem.

no1uno
13-Jan-2007, 05:01 PM
I got it! :D

I hadn't realised that %nextnum% was changing the number on the text file on my server, so now I know how this function works and that it is working.
Next I placed the below code into my form.


<input type="hidden" name="derive_fields" value="Counter=%nextnum%,subject=subject+%nextnum%

Now I get the subject and the unique number in my email subject line.
The only problem I had was that I wanted only the unique number to show in the thankyou page without the subject. I tried using $Counter, but it didn't work. But thats OK, it still works great.
This really is The most advanced FormMail (http://www.tectite.com/formmailpage.php) ever produced!
Hats off to a great Aussie product.

Cheers

anniew
14-Jan-2007, 01:25 AM
I'm struggling with this a bit... I've installed the form this evening, got everything going great. The problem I have is the counter counting for every mail it sends.

I've used the suggestion above to get the incremental number into the subject of the email sent to me. I've also added the $Counter into the autoresponder mail template to get the number as a reference in the customer mail.

Both of these are working and writing the numbers in the right places - but the numbers are different.

For example, I received the customer email with the counter at 1006 and my copy had 1008 (I started at 1000 in the file!). So, not only does it count for each mail, it misses one out too.

I'm using a template for each mail - is this causing the extra counting? I don't mind if they do skip numbers, particularly, but can I make it so the same number appears in both mails?

no1uno
14-Jan-2007, 02:57 AM
Hi anniew

I see what you mean, I only just noticed the problem now.

Russell, is this a characteristic of the functionality, or have we done something wrong?

Cheers

no1uno
14-Jan-2007, 05:39 AM
Ok, I sort of fixed mine.
I found the problem in :


<input type="hidden" name="derive_fields" value="Counter=%nextnum%,subject=subject+%nextnum%

The syntax : subject=subject+%nextnum% seems to be the problem. Once I removed this and just used the field $Counter in the body of the email, the unique number was the same in both my email and the thankyou page.
I ended up using


<input type="hidden" name="derive_fields" value="Counter=%nextnum%,subject=subject+LastName

to give in the subject line of the email : Online Order - (subject field) Smith (surname field).
At least I can now search on my emails to find a particular order.

russellr
14-Jan-2007, 11:07 AM
Hi,

You can't use fields in your thank you page if you use good_url. But, if you use good_template, then you can use fields, including derived fields.

Each time you derive a field with %nextnum%, the counter is incremented.

anniew: if you're getting skipping in the numbers, it can only be because you're using %nextnum% more than once in the same form

no1uno: the derivation you wanted is this:


<input type="hidden" name="derive_fields"
value="Counter=%nextnum%,subject=subject+Counter" />

anniew
14-Jan-2007, 11:18 AM
I knew it would be something obvious!

Thanks both of you - I've fixed it now and it's counting perfectly.