Coder
Coder

Reputation: 13

How do you get the value entered from a HTML textbox and send it to a specific mail ID?

I'm making a website where at the end of the page you fill in the mini form and provide your feedback. I've tried some code like this.

<form id="signup-form" method="post" action="mailto:[email protected]">
    <input type="text" name="email" id="email" placeholder="Email Address">
    <input type="submit" value="Sign Up">
</form>

But it didn't work. What I would like is the subject as the name and the body as the message. I don't need the email. So if you have a solution please let me know. Picture of the textboxes

Upvotes: 0

Views: 316

Answers (2)

Infoconic Technologies
Infoconic Technologies

Reputation: 414

To answer your question I need to use 2 things HTML + PHP combination. With HTML alone you can't really get the HTML textbox values straight to specific mail ID. I never tested it but I am sure we need to use server sided scripts.

You can do something like this.

HTML code

I'm making a website where at the end of the page you fill in the mini form and provide your feedback. I've tried some code like this.

<form id="signup-form" method="post" action="process.php">
    <input type="text" name="email" id="email" placeholder="Email Address">
    <input type="submit" value="Sign Up">
</form>

PHP code inside process.php. we need to use PHP mail function to send mail.

<?php
$email = $_POST["email"];
$to = "[email protected]";
$subject = "My subject";
$headers = "From: [email protected]" . "\r\n" .
"CC: [email protected]";

mail($to,$subject,$email,$headers);
?>

Make sure the action attribute URL specified in HTML form is correct. According to this code the HTML form and the process.php should be kept in same directory. If you need to place process.php at different location then make sure URl is correct.

Upvotes: 1

William
William

Reputation: 31

Please edit your question because there is no code posted currently. But typically, you would have something like this:

<form action=”mailto:[email protected]” method=”POST” enctype=”multipart/form-data” name=”EmailForm”>
<!-- your input elements go here -->
</form>

Upvotes: 1

Related Questions