FormMail Redirection

FormMail Redirection

Posted by: Jwheeler
Posted on: 2004-02-11 12:43:00

I am having trouble using the redirect function of the Form Mail cgi.

If i set the value of the hidden form element "redirect" manually in the HTML eg. value="http://mysite.com" then everything works fine.
However i need to modify that value via javascript.

i use an onclick event on a radio button to set the value to my desired URL.

onclick="document.Register.redirect.value='http://www.mysite.com';"

debugging proves that the variable gets set properly but somehow the CGI does not recognize the new value OR the default value once it has been changed. The result after form submission is the same as if no redirection was used and i get a formail report page.

Is there something i am doing wrong?

~John

Re: FormMail Redirection

Posted by: Atropos7
Posted on: 2004-02-11 18:03:00

Works for me. I made a testcase at http://openvein.org/testcase/form.pl

One thing that comes to mind is if you are making the form elements dynamically. You have to make sure the elements are being tied to the form that is being submitted. This means the control elements must be children of the form element, and the form element should be a child of the body element. Some people forget that when creating dynamic forms and then wonder why the data is not being submitted. It's easy enough to do this using the W3C DOM specification, however on some browsers the non-standard innerHTML property fails to do this. I don't think this is the case in your situation because if it were you'd probably getting "document.Register.redirect has no properties" error messages.

If you are still having problems, please try to post a more complete example of your code.



cool Perl / MySQL / HTML CSSEdited by Atropos7 on 02/11/04 06:06 PM (server time).

Re: FormMail Redirection

Posted by: Jwheeler
Posted on: 2004-02-11 18:38:00

Here is my code in it's entirety.
I have only one idea.. perhaps my values are formatted incorrectly.
the button at the top of the page tests the form and proves that the value is being set.. i believe it is the formmail cgi that is not handling the data correctly. You think it could be because of the & characters and such in the link?
If so perhaps the cgi is reading the url wrong or defaulting back to a regular report page because of it.

~John


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Online Registration</title>
<style type="text/css" media="screen"></style>
</head>

<body bgcolor="#ffffff">




<form id="Register" action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="POST" name="Register" enctype="Default">

<input id="ID_recipient_BC4E067C" type=hidden name="recipient" value="shood@hoodconsultingcorp.com">
<input id="ID_subject_BC4E067C" type=hidden name="subject" value="10K Race Web Registration">
<input id="ID_required_BC4E067C" type=hidden name="required" value="realname,address,city,state,zip,sex,shirt,event,email,phone,age,Verify">
<input type=hidden name="redirect" value="http://www.contactoffayetteville.org/raceAD/redir.html">





<div align="center">
<button name="buttonName" type="button" onclick="alert(document.Register.redirect.value);">Button</button>
<table width="400" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<div align="left">
<font size="5" face="Optima">On-line Registration Form</font></div>
</td>
</tr>
<tr height="3">
<td bgcolor="#9999ff" height="3">
<div align="right"></div>
</td>
</tr>
<tr>
<td valign="top">
<div align="right">
<font face="Optima"><label for="ID_FullName_BC4DFCE4"><font size="2" color="black">Full Name: </font></label><input id="ID_FullName_BC4DFCE4" type="text" name="realname" value="" size="40" maxlength="31"></font>

<font size="2"><font color="gray"><i>(eg. Dr. John H. Smith Jr.)</i></font></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font face="Optima"><label for="ID_address_BC4D7036"><font size="2" color="black">Address:</font></label><input id="ID_address_BC4D7036" type="text" name="address" value="" size="30" maxlength="40"></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font face="Optima"><label for="ID_city_BC4DFCF2"><font size="2" color="black">City:</font></label><input id="ID_city_BC4DFCF2" type="text" name="city" value="" size="30" maxlength="40"></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font face="Optima"><label for="ID_state_BC4DFCF8"><font size="2" color="black">State:</font></label><input id="ID_state_BC4DFCF8" type="text" name="state" value="" size="30" maxlength="40"></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font face="Optima"><label for="ID_state_BC4DFCFE"><font size="2" color="black">Zip:</font></label><input id="ID_state_BC4DFCFE" type="text" name="zip" value="" size="10" maxlength="5"></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font face="Optima"><label for="ID_phone_BC4DFD03"><font size="2" color="black">Phone:</font></label><input id="ID_phone_BC4DFD03" type="text" name="phone" value="" size="30" maxlength="40"></font></div>
</td>
</tr>
<tr>
<td>
<div align="right">
<font face="Optima"><label for="ID_email_BC4DFD09"><font size="2" color="black">Email:</font></label><input id="ID_email_BC4DFD09" type="text" name="email" value="" size="30" maxlength="40"></font></div>
</td>
</tr>
<tr>
<td align="right" valign="top">
</td>
</tr>
<tr>
<td>
<div align="right">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="150">
<div align="right">
<label for="ID_selectName_BC4E00F3"><font size="2" face="Optima">Event:</font></label></div>
</td>
<td width="50"><select id="ID_selectName_BC4E00F3" name="event" size="1">
<option selected>Choose Your Event</option>
<option value="RACE">10K Crossroads Race</option>
<option value="WALK">1-Mile Walk of Hope</option>
</select></td>
</tr>
<tr>
<td width="150">
<div align="right">
<label><font size="2" color="black">Sex:</font></label></div>
</td>
<td width="50">
<div align="left">
<select name="sex" size="1">
<option selected value="Male">Choose</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select></div>
</td>
</tr>
<tr>
<td width="150">
<div align="right">
<label><font size="2" face="Optima">T-shirt Size:</font></label></div>
</td>
<td width="50">
<div align="left">
<select name="shirt" size="1">
<option selected value="Male">Choose</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
<option value="X-Large">X-Large</option>
</select></div>
</td>
</tr>
<tr>
<td colspan="2" width="298">
<div align="right">
<font color="gray"><i><span style="font-size:10.0pt"><font size="1" face="Optima">(T-shirts will be given to the first 200 paid registrants.)</font></span></i></font></div>
</td>
</tr>
<tr>
<td width="150">
<div align="right">
<label><font size="2" color="black" face="Optima">Age on 3/20/04:</font></label></div>
</td>
<td width="50">
<div align="left">
<input type="text" name="age" value="" size="3" maxlength="20"><font color="gray" face="Optima"><i>yrs</i></font></div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td><font size="1" face="Optima">I understand that a 10K road race requires a level of physical fitness and health and entails associated risks. I am participating in this race freely and, for myself, my heirs, executors and administrators, waive and release any and all rights and claims for damages I have or may have against CONTACT of Fayetteville and/or the organizers and sponsors of this run and their representatives, as well as any and all claims of danger and actions whatsoever in any manner as a result of my participation in this race, including (but not limited to) any injuries I might suffer. I acknowledge that I am aware of the inherent risks involved in running such a race. I grant permission to all the foregoing to use any photographs, motion pictures, recordings or any other record of this event for any legitimate purpose.</font></td>
</tr>
<tr height="3">
<td bgcolor="#9999ff" height="3"></td>
</tr>
<tr>
<td>
<div align="right">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="320"><font size="2" color="black" face="Optima">I certify that I am at least 18 years of age and have read and understand all of the above.</font></td>
<td width="50"><input type="radio" name="Verify" value="Over18" onclick="document.Register.redirect.value='https://www.paypal.com/xclick/business=contact@contactoffayetteville.org&item_name=10k+Crossroads+Race+Registration+-+Adult&item_number=001&&image_url=http://www.contactoffayetteville.org/logo.gif&amount=15.75&no_shipping=1&cn=Additional+Comments¤cy_code=USD&lc=US';"></td>
</tr>
<tr>
<td width="320">
<p class="MsoNormal"><font size="2" color="black" face="Optima">I am under 18 years of age. My parent or legal guardian signifies that he/she has read and understands </font><font size="2" color="black" face="Optima">all of the above.</font>
</td>
<td width="50"><input type="radio" name="Verify" value="Under18" onclick="document.Register.redirect.value='https://www.paypal.com/xclick/business=contact@contactoffayetteville.org&item_name=10k+Crossroads+Race+Registration+-+Adult&item_number=001&&image_url=http://www.contactoffayetteville.org/logo.gif&amount=15.75&no_shipping=1&cn=Additional+Comments¤cy_code=USD&lc=US';"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr height="3">
<td bgcolor="#9999ff" height="3"></td>
</tr>
<tr>
<td>
<div align="left">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="bottom"><input type="reset" value="Clear"></td>
<td align="center" valign="bottom"><input type="submit" name="Submit" value="Proceed"></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Re: FormMail Redirection

Posted by: Atropos7
Posted on: 2004-02-11 19:12:00

Must be the formmail script, as I plugged your code into http://openvein.org/testcase/form2.pl and the redirect value is being submitted.

Is the recipient field being set correctly? It doesn't appear to be an e-mail address though perhaps you munged it for posting here.

Also, why is enctype set to "Default" ? Here is the HTML 4.01 specification:

In reply to:

enctype = content-type [CI]
This attribute specifies the content type used to submit the form to the server (when the value of method is "post"). The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file".


Change enctype="Default" to enctype="application/x-www-form-urlencoded" (or leave it out altogether)




cool Perl / MySQL / HTML+CSS

Re: FormMail Redirection

Posted by: will
Posted on: 2004-02-11 19:18:00

If you're going to post a really big section of code like this, try to post a link to it rather than posting the code directly into the forum.

If you name the file 'blah.html.txt", I think it'll show up as text.

Tags: form mailredirectmysiteredirectionhttpformmailradio buttondebuggingrecognizesubmissionelementjavascripturl