I've been trying to figure out how to use the canned tools on my ISPs web site to create an email form. Most of it is a simple form (only text fields and areas) but the gotcha is attaching a file to the created email.
I started out trying to use cgiemail. Despite having found documentation on how to attach a file, it wouldn't accept any "enctype". So I switched to the other option available to me, FormMail.cgi (which is a clone of the original). That's what I've been fighting with for the last two days.
The HTML code follows. Dreamweaver created the Javascript that does the data validation.
I've also noticed that the "from_email" and "from_name" don't seem to be working. I'll really appreciate your help.
David
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h2 align="center">Paper Proposal for
Rome, Italy, May 22-23, 2007</h2>
<form name="form1" method="post" action="/cgi-sys/FormMail.cgi" enctype="multipart/form-data">
<input type="hidden" name="recipient" value="
[email protected]">
<input type="hidden" name="from_email" value="
[email protected]">
<input type="hidden" name="from_name" value="send only address">
<input type="hidden" name="subject" value="Submission of abstract">
<h3 align="center">Submitter Information
</h3>
<table width="100%" border="0" cellpadding="3" cellspacing="3" name="submit_paper_tbl" align="center">
<tr>
<td><i><b>Required
fields are italicized</b></i></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<tr>
<td>
<div align="right"><i>Last
Name:</i></div>
</td>
<td>
<input type="text" name="lname">
</td>
<td>
<div align="right"><i>First
Name:</i></div>
</td>
<td>
<input type="text" name="fname">
</td>
</tr>
<tr>
<td>
<div align="right">M.I.:</div>
</td>
<td>
<input type="text" name="midinitial">
</td>
<td>
<div align="right">Title:</div>
</td>
<td>
<input type="text" name="title">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<div align="right"><i>Company:</i></div>
</td>
<td valign="top">
<textarea name="company" cols="75" rows="2"></textarea>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<div align="right"><i>Address:</i></div>
</td>
<td valign="top">
<textarea name="address" rows="5" cols="75"></textarea>
</td>
</tr>
<tr>
<td>
<div align="right"><i>Phone
Number:</i></div>
</td>
<td>
<input type="text" name="phonenum">
</td>
</tr>
<tr>
<td>
<div align="right"><i>Primary
Email:</i></div>
</td>
<td>
<input type="text" name="email1" size="75">
</td>
</tr>
<tr>
<td>
<div align="right">Secondary
Email:</div>
</td>
<td>
<input type="text" name="email2" size="75">
</td>
</tr>
<tr>
<td>
<div align="right"><i>Attach
Abstract (in Microsoft Word format please):</i></div>
</td>
<td>
<input type="file" name="abstract" size="50">
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="reset" name="clearform" value="Clear Form">
<input type="submit" name="submit" value="Submit Proposal" onClick="MM_validateForm('lname','','R','fname','' ,'R','phonenum','','R','email1','','RisEmail','com pany','','R','address','','R');return document.MM_returnValue">
</div>
</td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>