I am trying to combine the name field with the email field so that the email will be delivered like:
From: Name of Person Filling Out Form (email_address.com)
Goal: (Email From Line would contain the person's name and email).
I am using 1and1's mail.php function and there are no instructions on how to do this.
Is this even possible?
Here is my code:
<?php
echo '<link href="new/css/style.css" rel="stylesheet">';
// THE BELOW LINE STATES THAT IF THE SUBMIT BUTTON
// WAS PUSHED, EXECUTE THE PHP CODE BELOW TO SEND THE
// MAIL. IF THE BUTTON WAS NOT PRESSED, SKIP TO THE CODE
// BELOW THE "else" STATEMENT (WHICH SHOWS THE FORM INSTEAD).
if ( isset ( $_POST [ 'buttonPressed' ] )){
// REPLACE THE LINE BELOW WITH YOUR E-MAIL ADDRESS.
$to = 'myemail.com' ;
$subject = 'From PHP contact page' ;
// NOT SUGGESTED TO CHANGE THESE VALUES
$message = $_POST [ "message" ] ;
$headers = 'From: ' . $_POST[ "from" ] . PHP_EOL ;
$name = $_POST['name'];
mail ( $to, $subject, $message, $headers ) ;
// THE TEXT IN QUOTES BELOW IS WHAT WILL BE
// DISPLAYED TO USERS AFTER SUBMITTING THE FORM.
echo '<div id="msg_sent"> Your e-mail has been sent. You should receive a reply within a week. </div>';}
?>
Thank you if you know anything!