Page 1 of 1

processing form to be sent to email adress

Posted: Sun Oct 12, 2003 10:00 pm
by gavinbsocom
Im unclear on if someone came to my site, and i wanted them to fill out a form and they pressed submit, how to get it sent to me?


<form action="<a href="mailto:whoever@.com"></a>" method="post">


can I put that as the action and it will get sent there? or is there a differnt way to do it?

Posted: Sun Oct 12, 2003 11:12 pm
by volka
the action property takes an url as value not an anchor element.
Try

Code: Select all

<html>
	<head>
		<title>client-side email</title>
	</head>
	<body>
		<A HREF="mailto:account@your.host?subject=A%20Subject&body=Some%20text">Send me an email</A>
		
		<form action="mailto:account@your.host?subject=A%20Subject" method="POST" enctype="text/plain">
			<input type="text" name="username" /><br />
			<textarea name="comment"></textarea><br />
			<input type="submit" />
		</form>
	</body>
</html>
Always add the enctype property. Without netscape/mozilla-based browsers will not include the field values

Posted: Mon Oct 13, 2003 12:04 am
by gavinbsocom
thats amazing, thankyou, but one quick question. why do you need the ? inbetween the email and the other thing. and 2 is subject a set thing can i chage thesubject to subject=info? also what does the enctype do? encript it?

<html>
<head>
<title>client-side email</title>
</head>
<body>
<A HREF="mailto:account@your.host?subject=info">Send me an email</A>

<form action="mailto:account@your.host?subject=info" method="POST" enctype="text/plain">
<input type="text" name="username" /><br />
<textarea name="comment"></textarea><br />
<input type="submit" />
</form>
</body>
</html>

Posted: Mon Oct 13, 2003 1:18 am
by volka
the ? in a link separates the path from the parameters, i.e. subject is the parameter-name and info the value of this parameter .
take e.g. a look at the link that lead you here
viewtopic.php?t=13532
t=13532 is the parameter name/value pair that the script uses to find the thread you wanted.
and the common mailto:// implementation uses the parameter subject to fill in the subject-field

for enctype read http://www.w3.org/TR/html4/interact/for ... ef-enctype

Posted: Mon Oct 13, 2003 9:17 am
by m3rajk
umm.. you might want to mention that you'll need to use asp or php to send e-mail in a form in xhtml. possibly html4.01 as well. i think thats been deprecated

Posted: Mon Oct 13, 2003 5:51 pm
by gavinbsocom
yah i was wondering about that, cause when I submitted the form it opened outlook expres.. I want it to just send it to the designated email adress. I would like to do it in php...can any one just give me a link or a little help on where to get started. Thankyou very much.

Posted: Mon Oct 13, 2003 8:45 pm
by m3rajk
http://www.php.net

search for the function: mail

Posted: Mon Oct 13, 2003 8:55 pm
by m3rajk
hmm... on second thought i will.... here's an outline of a self processing form, just so you can use it to create one to play with...

Code: Select all

<?php
if(isset($_POST['process'])){
  $err=FALSE; $errs=array();
  /* make sure everything is ok (if not, set err to TRUE and place errors in errs array) */
  if(!($err)){
   /* set up the body */
   /* set up the headers */
   /* set up the subject */
   mail($to, $sub, $body, $headers); // send the mail
   }
}

if((!(isset($_POST['process'])))||($err)){ // if process isn't set, OR there's an error

/* give the frm, and any possible error messages */

}

?>