Arcanum has asked for the wisdom of the Perl Monks concerning the following question:
I'm attempting to write a form that redirects users to certain pages based on their domain name. They must choose webmail or email administration, and then type their domain. When they submit, the script will redirect them to the proper page based on their input. Here's the code:
# takes input from a form and redirects # users to proper web page use CGI qw(:standard); my $domain = param("domain"); my $type = param("type"); if ($type eq 'webmail' && $domain ne ''){ print "Content-type: text/html\n\n"; print "<html><head><META http-equiv=\"refresh\" content=\"0; url=h +ttp://mail.$domain/cgi-bin/sqwebmail\">\n"; print "</head></html>\n"; } elsif ($type eq 'admin' && $domain ne ''){ print "Content-type: text/html\n\n"; print "<html>\n"; print "<head>\n"; print "<META http-equiv=\"refresh\" content=\"0; url=http://mail.$ +domain/cgi-bin/qmailadmin\">\n"; print "</head>\n"; print "</html>\n"; } else { print header(), start_html("Mail Login"); print "<form action=\"/cgi-bin/maillogin.pl\" method=\"POST\">\n"; print "<p><input type=\"radio\" name=\"type\" value=\"webmail\">\n +"; print "Webmail Login</p>\n"; print "<p><input type=\"radio\" name=\"type\" value=\"admin\">\n"; print "E-mail Administration</p>\n"; print "<p>Domain name (without \"www\"): <input name=\"domain\"></ +p>\n"; print "<p><input type=\"submit\" value=\"Go to login\"></p>\n"; print "</form>\n"; }
I wrote this quickly to get started. It works just fine, with an exception: If the domain is mistyped, I will be redirected to a nonexistent page and I get the DNS error in the browser. I can deal with that; it's not my problem if people can't spell their domain names. The real problem is if the "back" button is pressed in the browser. The variables still have the incorrect values and I'm stuck in a loop.
Maintaining a list of domain names for validation would be difficult at this point for a few reasons. Is there some way I can rewrite the script to avoid the above behavior?
Thanks in advance for any help. Oh, and by the way, the lack of a shebang line is due to the fact that this is running on a Win server with IIS.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with form submission and redirect
by Aristotle (Chancellor) on Aug 26, 2002 at 16:47 UTC | |
by Arcanum (Sexton) on Aug 26, 2002 at 17:05 UTC | |
by talexb (Chancellor) on Aug 26, 2002 at 18:15 UTC | |
by Anonymous Monk on Aug 26, 2002 at 23:05 UTC | |
by Anonymous Monk on May 10, 2013 at 06:37 UTC | |
|
Re: Problem with form submission and redirect
by fglock (Vicar) on Aug 26, 2002 at 16:25 UTC | |
by Arcanum (Sexton) on Aug 26, 2002 at 16:37 UTC | |
by merlyn (Sage) on Aug 26, 2002 at 17:32 UTC | |
|
Re: Problem with form submission and redirect
by zentara (Cardinal) on Aug 28, 2002 at 00:24 UTC |