Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Form data via PHP

I am completely new to PHP scripts and have put together the following code, but I would like the email received to show it is sent from the email field in the HTML form rather than the current "The Tranquility Zone Website [[email protected]]". Please can you advise what I should change. Many thanks.

<?
$msg .= "Name:\t $_POST[name]\n";
$msg .= "E-mail:\t $_POST[email]\n";
$msg .= "Telephone:\t $_POST[telephone]\n";
$msg .= "Subject:\t $_POST[subject]\n";
$msg .= "Message:\t $_POST[message]\n";

$to = "[email protected]";
$subject = "Website feedback message";


$headers = 'From: '.$email_from."\r\n".
            'Reply-To: '.$email_from."\r\n" .

$mailheaders = "From: The Tranquility Zone Website <www.tranquilityzone.co.uk>\n";
$mailherders .= "Reply to: $_POST[sender_email]\n";


header( "Location: http://www.tranquilityzone.co.uk/thank_you.html" );

@mail ($to, $subject, $msg, $mailheaders);
?>
like image 632
user1076476 Avatar asked Dec 01 '11 23:12

user1076476


1 Answers

Change your code to this:

<?php
    $msg .= "Name:\t ".$_POST['name']."\n";
    $msg .= "E-mail:\t ".$_POST['email']."\n";
    $msg .= "Telephone:\t ".$_POST['telephone']."\n";
    $msg .= "Subject:\t ".$_POST['subject']."\n";
    $msg .= "Message:\t ".$_POST['message']."\n";

    $to = "[email protected]";
    $subject = "Website feedback message";


    $headers = 'From: '.$_POST['email']."\r\n".'Reply-To: '.$_POST['email']."\r\n" .

    $mailheaders = "From: ".$_POST['email']."\n";
    $mailheaders .= "Reply to: ".$_POST['email']."\n";


    header( "Location: http://www.tranquilityzone.co.uk/thank_you.html" );

    @mail ($to, $subject, $msg, $mailheaders);
?>
like image 162
vdbuilder Avatar answered Sep 19 '22 16:09

vdbuilder