So I made a form for my site it looks good and everything, except for one problem. How do I make it so when users hit submit the form email gets emailed to me? Right now when I hit submit it doesn't do anything except refresh.
Your 'form method' isn't correct. See the following code: <CENTER> <FORM METHOD=POST ACTION="mailto:someone@$nailmail.com" ENCTYPE="text/plain"> <INPUT TYPE="text" NAME="username"> : name <BR /> <INPUT TYPE="text" NAME="email"> : email <BR /> comments <BR /> <TEXTAREA NAME="COMMENTS" ROWS="10" WRAP="hard"> </TEXTAREA> <INPUT NAME="redirect" TYPE="hidden" VALUE="index.html"> <INPUT NAME="NEXT_URL" TYPE="hidden" VALUE="index.html"> <BR /> <INPUT TYPE="submit" VALUE="Send"> <INPUT TYPE="reset" VALUE="Clear"> </FORM> </CENTER> <!-- END OF FORM --> Code (markup):
Search google for a free php contact form script. It's easy to set up, theres a few setup tutorials out there.
It's not invalid but annoying! Rather than using mailto, which forces the user to open their e-mail client and more (also you will probably get a whole load of spam) you should just use the PHP mail function to send it across.
Is their any other way for me to get the information? The only reason being that I am using an HTML form. I have looked into something like this: <form name="input" action="html_form_submit.asp" method="get"> HTML: But when I look at the file it dosen't have anything in it.
Well Basically you need to use a short script in order to automatically send the data from a form to your e-mail. The most commonly used way to do this is via PHP, for example this is how I would do it: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if($_POST['submit']){ //Then the Form has Been Submitted //Assign the Variables $input1 = $_POST['input1']; $input2 = $_POST['input2']; //Now let's send the mail //E-mail to Send the Comments to $to = "my-mail@example.co.uk"; //Subject of the E-mail $subject = "Testing Feedback Commments"; //Contents of the E-mail $message = "My Message Goes here \n The user entered $input1 into the input1 box They also entered $input2 into the input2 box"; //E-mail Headers $headers = "From: webmaster@mysite.com"; //Here We Actually Send the Mail $mail_sent = mail( $to, $subject, $message, $headers ); //Confirm Success echo $mail_sent ? "Mail sent" : "Mail failed"; } ?> <form id="feedback-form" action="" method="post"> <label for="input1">Input Example 1:</label> <input type="text" name="input1" id="input1" /> <label for="input2">Input Example 2:</label> <input type="text" name="input2" id="input2" /> <input type="submit" name="submit" value="Send Comments" /> <!-- #feedback-form --></form> </body> </html> PHP: You already say you have the form setup, so just change this so the opening form tag has in it: <form action="" method="post"> Then you just change the variables in the script, where it says "Assign the Variables", you change the input1 part in $_POST['input1'], to the name of one of your fields, and repeat this for all of your fields. Then change the e-mail and test it out! Just post you whole code if you are still having problems.
Use wd_2k6's Code Also, if you host that code in an external file (let's say "sendmail.php") then you should use <form action="sendmail.php" method="post">
Thanks for all the help guys, I was able to get it working by using cgiemail and it works now. The only problem is that I am trying to put this form in side of a forum and the form generator I used made a separate form.html and form.css file. Is their anyway I can put the CSS file into the HTML file without to much trouble?
If you run code with capital letters(tags) in Markup Validation Service your code will not validate element "CENTER" undefined. Did you mean "center"?