View Full Version : Formmail questions
I've been testing with the FormMail and everything is working ok.
Still a few questions about customizing it:
* What can I change if I want an input field to be checked for spaces. For ex. I have a field that requiers First name and surname. Sometimes only the first name is filled in. I thought by checking if there's a space I could verify if both names are given.
*[solved] I have a selection drop down box. The first line is 'Make your choice'. I would like to check if the user made a choice that is not that first one. So, if they leave it on 'Make your choice, it should go to the error page.
* [solved]When I receive a mail through the form it shows everything like it should, but there's also 'submit: send' from the submit button. Is it possible to leave this out of the mail?
* Is it possible to have a summery of the submitted data on the thank you page?
I can do these things in PHP, but have no idea how to do it with formMail.
Also, I would like a non-javascript solution for these problems, as javascript can be disabled.
Thx in advance
shyam
10-19-2007, 07:53 AM
which formmail script are u using? where did u download it from or can u post the script?
I thought I forgot something :rolleyes:
This is the script (nms FormMail)
http://nms-cgi.sourceforge.net/scripts.shtml
shyam
10-19-2007, 07:55 PM
you can only check if a certain required field is missing and not send the mail...
adding hidden form fields with name required will make sure that the required fields are present...giving an empty value to the select will ensure that it also becomes a required field
<input type="hidden" name="required" value="FirstName" />
<input type="hidden" name="required" value="SurName" />
<input type="hidden" name="required" value="selectName" />
<input type="hidden" name="missing_fields_redirect" value="redirect here if fields missing" />
<select name="selectName">
<option value="">Make your choice</option>
...
</select>
the other configurations that are available are listed in the script which are
recipient
subject
email
realname
redirect
bgcolor
background
link_color
vlink_color
text_color
alink_color
title
sort
print_config
required
env_report
return_link_title
return_link_url
print_blank_fields
missing_fields_redirect
to leave out any form fields u've gotta customize the script and add some code of your own
Thanks for the reply.
I have the hidden fields.
<input type="hidden" name="required" value="email,realname,info,onderwerp">
I hadn't given the 'Make your choice' option an empty value, so that's solved!
Thanks :thumbsup:
For the first and surname issue:
I have only 1 field, because
realname - If one of the things you're asking the user to fill in is their
full name and you call that input 'realname', formmail will use
it as the name part of the sender's email address in the mail.
So, I have
<input name="realname" type="text" id="naam">
but that means that I can't check if they gave their full name.
I was hoping their is a way to check this by maybe checking for a space.
There is an option for an auto generated success page, but that pages is boring and in English (my client speaks Dutch).
I have tried putting my html and javascript code in the .pl file but that gives me an error 500.
So I thought using a custom thank you page would be the solution by adding
<input type="hidden" name="redirect" value="../thankyou.html" />
to my contact page. But I can't figure out how to include the submitted data.
to leave out any form fields u've gotta customize the script and add some code of your own
I have no idea how to do that :confused:
Philip M
10-20-2007, 09:07 AM
You can use JavaScript to check that the full name is entered:-
function checkName() {
var temp = document.formname.elementname.value;
if (!/(^[A-z]{2,}\s+[A-z-']{3,}$)/.test(temp.value)) {
alert ("Invalid name - please re-enter")
document.formname.elementname.value = "";
document.formname.elementname.focus();
}
}
or if the value is passed with the this keyword:-
function checkName(which) {
var temp = which.value;
if (!/(^[A-z]{2,}\s+[A-z-']{3,}$)/.test(temp.value)) {
alert ("Invalid name - please re-enter")
which.value = "";
which.focus();
}
}
But be aware that the test is for two or more letters, space(s), three or more letters. But some names have hyphens or apostophies (Smith-Jones, O'Leary) - this is allowed for.
shyam
10-20-2007, 02:01 PM
<input type="hidden" name="redirect" value="../thankyou.html" />
to my contact page. But I can't figure out how to include the submitted data.
the script uses cgi redirect (http://search.cpan.org/dist/CGI.pm/CGI.pm#GENERATING_A_REDIRECTION_HEADER) that does not work with relative urls so give the absolute url and it should work
I have no idea how to do that :confused:
somewhere in the formmail script replace the highlighted code in this function given below
sub remove_blank_fields {
my ($self) = @_;
return if $self->{FormConfig}{print_blank_fields};
$self->{Field_Order} = [
grep { defined $self->{Form}{$_} and $self->{Form}{$_} !~ /^(\s*|send)$)/ }
@{ $self->{Field_Order} }
];
}
@Philip M:
thanks, but I was looking for a non javascript solution, because I see it as a small anti spam security extra and spambots can turn off javascript.
@shyam:
The code didn't work for me, but I've found another easy solution by using 'sort' in my contact page.
<input type="hidden" name="sort" value="order:telefoon,email,onderwerp,info">
It doesn't only sort but also leaves out anything you don't mention in the values :rolleyes:
the script uses cgi redirect that does not work with relative urls so give the absolute url and it should work
in the contactpage you can use relative urls.
I have made 2 testpages:
This one (http://deep-impact.be/formulier.php) uses the relative url redirection to the thankyou html I have uploaded. But I don't know how to display the entered data
This one (http://deep-impact.be/formulier2.php) the html page generated by the script.
As you can see in the last one, adding an image tag is no problem, but when I add my complete code (images, javascript,...) i get error 500 messages, so I must be doing something wrong there. Also, if I use this, the page is in English, uses the variable names and leaves out all the things you don't mention in the sort tag. If I add every field in the sort tag then some data is mentioned more than once in the email.
That cpan page will help me a lot I think!
Anyway, I will have a look at this on monday
shyam
10-20-2007, 04:05 PM
It doesn't only sort but also leaves out anything you don't mention in the values :rolleyes:
now u've got the hang of it :D...maybe /^(\s*|Zenden)$)/ would have worked...but, i like ur solution...its much more cleaner
if ur using the redirect the values do not get passed on to the redirect page so, if u want to reuse the values u've to meddle with the script like u've done in the second case...
/^(\s*|Zenden)$)/ would have worked...
Aaargghh !!!!
if ur using the redirect the values do not get passed on to the redirect page so, if u want to reuse the values u've to meddle with the script like u've done in the second case...
I'll do some testing on monday.
One more question:
There's a 8/9 hour difference between the server (somewhere in California) and the location of my client (GMT+1) depending on daylight saving. Where and how can I change that?
in PHP I use
setlocale(LC_TIME, 'nl_BE');
$todayis = gmstrftime("%d %B %Y - %H:%M uur",time()+7200);
but in PERL...... :confused:
KevinADC
10-20-2007, 06:19 PM
It is very similar in perl. Find in the script where the time stamp is generated and add the time in seconds to "time" or localtime() or gmtime(), whichever is being used in the script.
(60*60)*hours = seconds
thanks for the reply!
While looking for time() in de .pl file I've found
date_offset => ' ',
Time in the .pl file is set to GMT, so I had to change it to
date_offset => '2',
Another problem solved :thumbsup:
Now for the layout of the success page....
I managed to give the error and success page the look I wanted by adjusting the .pl file. :D
So, everything is solved except the first problem (checking for spaces), but that is not that important.
I will use the javascript Philip M posted for the moment, or maybe I will leave it as is.
Thanks again for the help people!!!
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.