Hello.I have contact form.Here is the code <header> <h1>Contact me</h1> </header> <section> <p>You can write your comments about our website or you can submit your own potato recipe to us!</p> <form method="post" action="mailto:"> <label for="nm">Name: </label> <input type="text" id="nm"> <label for="em">Email: </label> <input type="text" id="em"> <label for="comm">Your comments: </label> <textarea id="comm"></textarea> <br> <input type="submit" value="Send email"> </form> </section> When i write message in Your comments field and press submit,then email client opens a tab to write a new message.But i don't want that.I want that message would be sent straight,just when person write in "Your comments" field and press submit. So,i can't do that just with html? Can you write me the easiest and fastest way to do that?Better with javascript,but if it is not possible then with php. Can you write the whole code here? Thank you.
it is not possible just with html you need php to process the request, there are plenty of free php contact form tutorials out there
<?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $formcontent="From: $name \n Message: $message"; $recipient = ""; $subject = "Contact Form"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!"; ?>
Ok,can you tell,how the whole code will look?I don't know where insert it.Should i first create form.php and then do code like this: <form> <few input types and button> <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $formcontent="From: $name \n Message: $message"; $recipient = ""; $subject = "Contact Form"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!"; ?> </form>