Zifweb
03-10-2003, 10:53 AM
I'm script-illiterate, and was wondering how exactly I could get a form on a webpage to be automatically mailed to a fixed email address every time it's submitted. I have the javascript in the HTML, I just don't know what I'd need server-side for it to work. :confused:
If I got it right, I'd need a CGI script for this to work, right? :confused:
If so, could anyone point me in the right direction as to where I could get a script that would do that? Or a tutorial or something that tells me how to make one? :D
The form I'm going to use is extremely simple, just name, email and comment fields, with a fixed subject line.
Exact javascript follows:
<!-- Begin
function checkFields() {
missinginfo = "";
if (document.form.name.value == "") {
missinginfo += "\n - Name";
}
if ((document.form.from.value == "") ||
(document.form.from.value.indexOf('@') == -1) ||
(document.form.from.value.indexOf('.') == -1)) {
missinginfo += "\n - Email address";
}
if(document.form.comments.value == "") {
missinginfo += "\n - Comments";
}
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}
// End -->
And in the body:
<form name=form onSubmit="return checkFields();">
<input type=hidden name=to value='some@thing.com'>
<input type=hidden name=subject value="Feedback">
<pre><font>
Name: <input type=text name="name" size=30>
E-mail: <input type=text name="from" size=30>
Comments:</font>
<textarea rows=3 cols=40 name="comments"></textarea>
<input type=submit name="submit" value="Submit Form!">
</pre>
</form>
Well, hope someone can help me out with this... :D
If I got it right, I'd need a CGI script for this to work, right? :confused:
If so, could anyone point me in the right direction as to where I could get a script that would do that? Or a tutorial or something that tells me how to make one? :D
The form I'm going to use is extremely simple, just name, email and comment fields, with a fixed subject line.
Exact javascript follows:
<!-- Begin
function checkFields() {
missinginfo = "";
if (document.form.name.value == "") {
missinginfo += "\n - Name";
}
if ((document.form.from.value == "") ||
(document.form.from.value.indexOf('@') == -1) ||
(document.form.from.value.indexOf('.') == -1)) {
missinginfo += "\n - Email address";
}
if(document.form.comments.value == "") {
missinginfo += "\n - Comments";
}
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}
// End -->
And in the body:
<form name=form onSubmit="return checkFields();">
<input type=hidden name=to value='some@thing.com'>
<input type=hidden name=subject value="Feedback">
<pre><font>
Name: <input type=text name="name" size=30>
E-mail: <input type=text name="from" size=30>
Comments:</font>
<textarea rows=3 cols=40 name="comments"></textarea>
<input type=submit name="submit" value="Submit Form!">
</pre>
</form>
Well, hope someone can help me out with this... :D