Click to See Complete Forum and Search --> : Forms Drive Me Nuts!


Jonathan
06-26-2003, 06:29 PM
Here is the source code...

<HTML>
<HEAD>
<META http-equiv="Page-Enter" CONTENT="RevealTrans(Duration=2,Transition=3)">
<TITLE>Prayer Requests</TITLE>
<body bgcolor="#3399FF">
<body text="black">
</head>

<body>
<H1>Prayer Requests</h1>
<HR>
<h3>Please enter your prayer request below.</h3>
<BR>
<Form method="post" action="mailto:support@crosspoint.org" enctype="text/plain">
Type your prayer here:<br>
<Textarea name="Pray for this:" Rows=20 cols=40></textarea>
<BR>
<FIELDSET>
<LEGEND><b>~Remember~</b></LEGEND>
Your prayer needs are confidential, so you don’t need to give an e-mail address.<BR>
<BR>
But if you would like one of the pastors or other leaders to contact you, then please enter you e-mail below.<BR>
<input type="text" name="E-mail:" Size="30">
<BR>
</fieldset>
<BR>
<P>
<input type="submit" value="SEND YOUR PRAYER"><input type="reset" value="RESET INFORMATION">
</form>
<BR>
<BR>
</body>
</html>

So how come when you click submit it just goes to a regular mailto: command?... the website is here: www.crosspoint.org/Prayer.html

Charles
06-26-2003, 07:11 PM
<Form method="post" action="mailto:support@crosspoint.org" enctype="text/plain">

What is it that you want this form to do?

spufi
06-27-2003, 12:29 AM
It's going to the mailto: command becasue that's what you are telling it to do in your code. <Form method="post" action="mailto:support@crosspoint.org" enctype="text/plain">

What server side code are you allowed to use? Here's what I have for my site, but it uses PHP. If you can't use PHP then ignore this part.

Here's my form...

<form method="post" action="confirm.php">
<div>Name:</div>
<div><input type="text" name="Name" /></div>
<div><sup class="req">*</sup>E-mail:</div>
<div><input type="text" name="EMail" /></div>
<div>Comments:</div>
<div><textarea cols="50" rows="5" name="Comments"> </textarea></div>
<div>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</div>
</form>

Here's the PHP on my confirm.php page...

<!-- Begin edit here -->
<?php
header("Refresh: 3; URL=/index.html");
echo " "; // NN4 requires that we output something...
exit();
$msg = "Email from your website.\n";
$msg .= "From: $Name \n";
$msg .= "E-Mail: $EMail \n";
$msg .= "$Comments";
$email_to = "me@matts-website.net";
$frome = "From: $EMail";
$subject_line = "Matt's Website e-mail.";
$Name = trim($Name);
mail($email_to,$subject_line,$msg,$frome);
echo "Your email has been sent to me and I will read it as soon as possible.";
?>
<!-- End edit here -->

I also added this <meta> tag in my confirm.php page to refresh the page to my home page.

<meta http-equiv="refresh" content="5; url=index.html">

Hmm, I already have a refresh in my header info. I'll have to play around with this to make it correct, but it still should work.

pyro
06-27-2003, 07:31 AM
If I may make a suggestion about your PHP code, I would say that you should program assuming global variables are off, as they now are as a default since PHP 4.2.0 (though many hosts manually turn them on). So, this line:
$msg .= "From: $Name \n";
should be:
$msg .= "From: $_POST["Name"]\n";

and the rest would be along those same lines.

spufi
06-27-2003, 11:12 AM
Well that's what I fet for taking code from somebody else. :p I'll rework the code later on today. Thanks.

pyro
06-27-2003, 11:33 AM
lol... :D

While you are switching, you may just want to use a loop to loop through all the $_POST vars. That way, if you ever use a form with more than message files, it won't be a problem. Something like this one here: http://forums.webdeveloper.com/showthread.php?s=&threadid=9543#post48748