Click to See Complete Forum and Search --> : Formmail.cgi script changes


stellakebab
06-18-2007, 06:46 AM
All,

I'm using a formmail.cgi script and would like to have it setup so that when users submit there information, along with the information being sent to myself, it also sends the info back to the recipient using the email address that they have entered in the form.

I believe the code should be something like:

<input type="hidden" name="recipient" value="me@mydomain.com, this.form.Email.value();"

but for some reason, it doesn't work, have i got the code wrong, can anyone suggest what the code should be?

Code that i have is as follows:

<form action="http://mydomain.com/cgi-bin/formmail.cgi" method="post" name="requestform" onsubmit="return IsValidForm(this)">
<input type="hidden" name="recipient" value="me@mydomain.com">
<input type="hidden" name="subject" value="Request form">
<input type="hidden" name="redirect" value="/reply/request.htm">
<input type="hidden" name="email" value="company@mydomain.com">
<input type="hidden" name="realname" value="company@mydomain.com">
<input type="hidden" name="required" value="Email, Name">

<table border="0" cellspacing="0" cellpadding="0" width="90%" align="left">
<tr bgcolor="#FFFFFF">
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td bgcolor="#6666CC"><img src="images/clear.gif" width="1" height="1"></td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="7" width="100%">
<tr>
<td align="right" valign="top" width="202" bgcolor="#e3e3ff" class="headline7">Name</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="Name" tabindex="1"></td>
</tr>
<tr>
<td align="right" valign="top" width="202" bgcolor="#e3e3ff" class="headline7">Department</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="Department" tabindex="2"></td>
</tr>
<tr>
<td align="right" valign="top" width="202" bgcolor="#e3e3ff" class="headline7">Email</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="EmailAddress" tabIndex="3"></td>
<tr>
<td align="right" valign="top" width="202" bgcolor="'#e3e3ff" class=headline7">Ext. Phone Number</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="ExtTeleNumber" tabIndex="4"></td>
</tr>
<tr>
<td bgcolor="#E3E3FF" class="headline7"></td>
<td colspan="5" bgcolor="#E3E3FF" class="headline7">
<input type="submit" name="submit" value="Submit the Information" tabIndex="17">&nbsp;<input type="reset" name="Reset" value="Reset all Values" tabIndex="18"></td>
</tr>
</table>
</td>
</tr>
</table>

I've left out some of the lines of code as these are business specific and I am unable to post these on the web. They are of no relevance to the problem that I am experiencing.

Can someone please help?

Donna

thamba
06-18-2007, 08:57 AM
I dont see any 'Email' element in your form. Its 'EmailAddress' that I see. Maybe thats your error.

stellakebab
06-18-2007, 08:58 AM
I have amended the code on my site so that the element is called EmailAddress, just haven't amended the code on this post.

stellakebab
06-19-2007, 05:36 AM
This code is still not working, and I have exhausted all my resources at work. Can someone please assist me.

<input type="hidden" name="recipient" value="me@mydomain.com, this.form.EmailAddress.value();"

but for some reason, it doesn't work, have i got the code wrong, can anyone suggest what the code should be?

Code that i have is as follows:

<form action="http://mydomain.com/cgi-bin/formmail.cgi" method="post" name="requestform" onsubmit="return IsValidForm(this)">
<input type="hidden" name="recipient" value="me@mydomain.com, this.form.EmailAddress.value();">
<input type="hidden" name="subject" value="Request form">
<input type="hidden" name="redirect" value="/reply/request.htm">
<input type="hidden" name="email" value="company@mydomain.com">
<input type="hidden" name="realname" value="company@mydomain.com">
<input type="hidden" name="required" value="Email, Name">

<table border="0" cellspacing="0" cellpadding="0" width="90%" align="left">
<tr bgcolor="#FFFFFF">
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td bgcolor="#6666CC"><img src="images/clear.gif" width="1" height="1"></td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="7" width="100%">
<tr>
<td align="right" valign="top" width="202" bgcolor="#e3e3ff" class="headline7">Name</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="Name" tabindex="1"></td>
</tr>
<tr>
<td align="right" valign="top" width="202" bgcolor="#e3e3ff" class="headline7">Department</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="Department" tabindex="2"></td>
</tr>
<tr>
<td align="right" valign="top" width="202" bgcolor="#e3e3ff" class="headline7">Email</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="EmailAddress" tabIndex="3"></td>
<tr>
<td align="right" valign="top" width="202" bgcolor="'#e3e3ff" class=headline7">Ext. Phone Number</td>
<td colspan="5" bgcolor="#e3e3ff" class="headline7"><input size="45" name="ExtTeleNumber" tabIndex="4"></td>
</tr>
<tr>
<td bgcolor="#E3E3FF" class="headline7"></td>
<td colspan="5" bgcolor="#E3E3FF" class="headline7">
<input type="submit" name="submit" value="Submit the Information" tabIndex="17">&nbsp;<input type="reset" name="Reset" value="Reset all Values" tabIndex="18"></td>
</tr>
</table>
</td>
</tr>
</table>

When i test this form, it receive an email in the me@mydomain.com mailbox, but on this email, contained within the To box is another address, but this states the webservers name (e.g. this.form.EmailAddress.value@webserver.co.uk ();)

This is now becoming very urgent that i get fixed, can someone please contact me. Either telling me how to get this to work, or either advising me of an alternative way of sending the details of the form to me and also to the recipient (using the contents of the EmailAddress textbox on the form).

Regards,

Donna

thamba
06-19-2007, 06:14 AM
Ok, I think I know what your problem is.
Using "this.form.EmailAddress.value();" inside your text field element is wrong. It will not insert the value of the EmailAddress field in there for you.

It would rather work if you inserted the value after submitting the form. Since you already have a javascript function 'isValidForm()', I suggest you add this line to that function so it executes after the form is submitted.

document.requestform.recipient.value += ',' + document.requestform.EmailAddress.value;

Add this line in that function. As seen above this will append the value of EmailAddress in the recipient field and then it should work for you.

thamba
06-19-2007, 06:16 AM
And yeah, remove that 'this.form.EmailAddress.value();' from inside the recipient form element. You wont need it in there.

stellakebab
07-05-2007, 06:44 AM
Thanks for that info, but unfortunately, it still doesn't seem to work.

I've changed the function and included the line and now the function looks like this:

<!-- begin
function IsValidForm(theForm) {

tmpSel = theForm.elements['Group'];
if (tmpSel.options[tmpSel.selectedIndex].value == 'Select...') {
alert('Please select a Group');
theForm.elements['Group'].focus();
return false;
}}

document.requestform.recipient.value += ',' + document.requestform.EmailAddress.value;

// end -->

Is there something else I should be putting either within this function, or within the form, so as it works?