I am trying to learn how to send email from a contact form using phpmail and post. I must include the 'from' field for the phpmail function to work on my server. I want to do this at the most basic level to help learn and add in things like striptags sanistising functions etc later, so far I have this code but it's not working so far, any ideas and help much appreciated, Emma :)
<html>
<body>
<form action="send.php" method="post">
First name: <input type="text" name="firstName"><br><br>
Last name: <input type="text" name="lastName"><br><br>
E-mail: <input type="text" name="email"><br><br>
<input type="submit">
</form>
</body>
</html>
And the php is this:
<?php
$email_message = ($_POST['firstname'],);
$email_subject = ($_POST['lastname'],);
$email = ($_POST['email']);
$email_to = "emmajane1@hotmail.co.uk"; // your email address send TO
$email_from = "admin@emmajane.website"; // your email address send FROM
$email_subject = "Contact form message";
/* Send the message using mail() function */
mail($email_to, $email_subject, $email, $email_message, $headers);
?>
I don't see a button to answer my own question, but at the most basic level I got it working with this script below, now I'm going to build the php script up layer by layer till I get to where I want.
<?php
$to = 'emmajane@hotmail.co.uk';
$subject = 'the subject';
$headers = 'admin@emmajane.website';
$message = $_POST['firstname'];
mail($to, $subject, $message, $headers);
?>