Log in

View Full Version : Form that submits AND redirects



ehooper
08-14-2007, 07:58 PM
I've read multiple solutions for this and not a one worked... copied EXACTLY and it doesn't work! (who's circulating this stuff?) Anyway, how do I get a form to both mailto:soandso@this.com AND redirect to a confirmation page at the same time. I had this:



<form name="formcheck" onsubmit="return formCheck(this);" action="emailcensored" method="post" enctype="text/plain" >

...

<INPUT type=submit value="Submit Form" Onclick="document.location='thankyou.htm';">


It worked just fine in IE, but in anything else it would just redirect before running the field validation script.

So, I'm stumped, can anyone help? (I also have a thread going in javascript forum to see if anyone can get the validation script to redirect for me)

Twey
08-14-2007, 08:23 PM
You don't -- pass it through a server-side script and have the script send an HTTP redirect.

ehooper
08-14-2007, 08:41 PM
I thought of that. I don't know how to do that. Share?

My form is importing data from a javascript run shopping cart in addtion to set page fields, so half my fields are new each time and always a different number, and i've had no luck writing anything that can move this data around for more than just direct email.

I'm sure there are other ways, and please, do share.

Twey
08-14-2007, 08:57 PM
It depends on what server-side languages you have available on your server.

ehooper
08-15-2007, 01:03 PM
basically cgi/perl is all this company has access to.

Twey
08-15-2007, 02:55 PM
In that case, something like:
#!/usr/bin/env perl

# ... send your mail here ...

print "Status: 303 See Other\r\n";
print "Location: /pages/mail/confirm.html\r\n\r\n";