using redirect in formMail

  caro456 15:07 23 Dec 07

I am using nms formMail on my website, but when the submit button is pressed, although everything works ok I would like the user to be redirected automatically to my confirmation page. I know I have to inset the following:
input type="hidden" name="redirect"
value="click here" />
as per the readme instructions, but am at a loss as to where to place the code. I am using netobjects fusion 10, and have tried placing it after the code for the submit button but it doesnt work - can anybody point me in the right direction? btw I have changed the value to the correct address.

  Kemistri 16:29 23 Dec 07

I haven't heard of NMS FormMail - is it this? click here

I can tell you how to add that feature to the PHP file, or I can post some example code, although I don't know whether you're OK with PHP yet. It will be up to you to decide what fields should be filled in in order to reach the success page.

Here's an example:

elseif (empty($firstname) || empty($surname) || empty($email) || empty($message)) {
header( "Location: http: //www." );

Place that between your POST entries section and your mail_message entries section. Choose which fields need to be used and add them to the above code, separated by the double pipes. That's the error check. Now the success bit:

header( "Location: http:// www." );

Place that at the end of the end of the mail_message section right before the closing bracket.

I can provide a complete example file if necessary.

  caro456 23:24 23 Dec 07

I haven't heard of NMS FormMail - is it this?

Yes that's the one - basically what I'm trying to do is put a contact form onto a website - my first!! - but I want it to be as secure from spambots as possible. So I have read posts here and done some research, but I seem to be tying myself in Knots. I'm pleased that I've managed to get the form to send the e-mail when the submit button is pressed, but that is as far as I've got. I know a little html, and no perl at all which is what the nms formmail script is written in. The formmail readme is good as far as it goes, in that it gives the code needed for the options but it doesn't tell you exactly where you need to put this code. Am I supposed to be adding it to the user customisation section of the script or in the html file? This is probably very basic knowledge that they expect you to know, but until I understand this I'm stuck!
Hadn't got as far as error checking the form yet!

  Forum Editor 00:10 24 Dec 07

it's that which will need editing. There will be a line in the script which mentions the url of the page to which you want people redirected on form submission.

Open the script in Notepad, make your alterations, and upload the script in the normal way.

  Kemistri 00:17 24 Dec 07

If you would like me to post the equivalent of a PHP file containing the code that I gave you, just post your form details (field IDs, basically). You can customize the URLs and choose the filename yourself. It will include direct call prevention (to keep it hidden) and CC/BCC prevention (to stop hijacking). Would that help?

  Forum Editor 08:36 24 Dec 07

Please don't post code in the forum, unless it's a small snippet.

If you want to offer help in this way it's better to use the small email envelope method to send directly to the person concerned - provided he/she agrees first.

  Kemistri 11:12 24 Dec 07

Yeah, that's OK - I was vague with my wording, but that's what I was going to do.

  SimpleSimon1 15:49 24 Dec 07

Hi caro456

> Yes that's the one - basically what I'm trying
> to do is put a contact form onto a website - my
> first!! - but I want it to be as secure from
> spambots as possible.

Like you, I know nothing about PHP or PERL but I found using nms FormMail was very easy and has proved very effective.

It would appear that many sources now regard Matt Wrights original FormMail script as insecure and recommend using nms FormMail as a drop-in replacement.

If you take at look here click here
it describes a very simple mod to this script (plus a hidden field on your form) to stop spambots using it to send you spam via the form.

Although I know nothing about PERL, after reading the above link and the 'rwedge solution' in the associated codingforums link, it took me slightly less than 2 mins to configure the script and implement the anti-spam changes in it and form. IMPORTANT: If you are going to do this, don't forget to comment out the as described in the blog comments.

Take a look at the html source on my contact form (click here) and you should see how it all hangs together. The key line you're looking for (which actually links the form to the script) is:

<form name="ContactForm" id="ContactForm" method="post" action="scripts/LetsTalk.cgi">

LetsTalk.cgi is simply the renamed FormMail script

Good luck

  caro456 22:12 24 Dec 07

Thanks for all your suggestions

Forum Editor - I've looked at the script so many times but cant see anything obvious that I can alter, however i think I have made some progress. In NOF I have managed to insert a hidden field into the form and named it redirect, giving the url as a value. This works a treat if I only put the main website address in, but as soon as I put /confirmation or /confirmation.html on the end to direct the user to a specific page, I'm back to square one - any ideas why that should be?

SimpleSimon1 - your html is neat, much more so than NOF, are you using css?

Kemistri - Thanks for your help, if it's not too much trouble I should like you to email me some PHP to have a look at. If it's as easily tweaked as you say, it could be a useful alternative. I have 3 fields on my form - Name, Email and a Comments box, then just the submit button. Thought I would start off simply and add to it as I get more to grips with it all!

  Kemistri 23:23 24 Dec 07

caro, if you can e-mail me (via the envelope) with the following details, I can compile the PHP so that you won't need to change anything in it. I'll then send you the file as an attachment.

[1] The full URLs of the form page, success page, and error page. (If you haven't created them yet, the success and error pages can just be very basic plain text with a link back to the home page, for example).
[2] The e-mail address to which your visitors' messages should be sent.
[3] The directory in which you want the PHP file (usually the same as the HTML page that uses it).

If you have not already done so, you will need to add the following line to the top of your form in the HTML:
<form method="post" action="form.php">
NOF may have added a near equivalent, in which case, just change the method and/or action as needed. If I remember right, you can choose the action for you form in NOF's palettes without having to get under the bonnet.

  SimpleSimon1 10:37 27 Dec 07


> SimpleSimon1 - your html is neat, much more so than
> NOF, are you using css?

Hhm,I can't really take much credit for the html since it was generated by Dreamweaver. About the only thing I did was clean it up a little since, like most 'drag&drop' tools, DW tends to leave a few empty tags around once you start editting the initial layout.

The layout is table-based and I'm only using very simple css for text formatting. Yes, I know all the purists will say that I shouldn't be using tables but I'm new to this and I needed a simple site quickly!

I promise that the mark 2 version of the site (coming some time "real soon") will use CSS rather than tables so please don't hate me :-)


This thread is now locked and can not be replied to.

Qualcomm Snapdragon 835 benchmarks: Antutu, Geekbench 4, GFXBench and PCMark results

1995-2015: How technology has changed the world in 20 years

This stop-frame animation tells a moving story of domestic violence for Refuge

New iPad 2017 preview: Apple's affordable but underspecced new iPad may appeal to the education…