I need to have the visitor of my website send form data (such as a contact form to my email via PHP. How will I be able to do this?
Asked
Active
Viewed 1,247 times
-2
-
2Possible duplicate of [Send email using the GMail SMTP server from a PHP page](http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page) – PacMan Jun 24 '16 at 04:13
-
3Possible duplicate of [Send email with PHP from html form on submit with the same script](http://stackoverflow.com/questions/18379238/send-email-with-php-from-html-form-on-submit-with-the-same-script) – UditS Jun 24 '16 at 05:39
1 Answers
1
With GET/POST query and using tag html forms / w3schools for example
.html page:
<form method="GET" action="send.php">
<input name="fieldname" type="text" placeholder="You text here...">
<input type="submit" value="Submit">
</form>
send.php
<?php
if (isset($_GET['fieldname']) {
// you code here..
}
example send email by function mail()
about mail() function on php.net
$from = 'fromemailsend@mail';
$to = 'emailtosend@mail';
$subject = 'your subject';
$message = 'your<br>message<br>in html code';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8 \r\n";
$headers .= 'To: Author <' .$to . ' >' . "\r\n";
$headers .= 'From: '.$author.' <'.$from.'>' . "\r\n";
mail($to, $subject, $message, $headers);

ixe
- 89
- 4