Easy PHP Email Script Question

I need to make a sender and a subject show up when the email is sent. Where would I put  it?


$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$childsname = $_POST['childsname'];
$childsage = $_POST['childsage'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$dayphone = $_POST['dayphone'];
$evephone = $_POST['evephone'];
$class1 = $_POST['class1'];
$class2 = $_POST['class2'];

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;

if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back Button To Make Changes</h2>\n";

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = "$todayis [EST] \n
Attention: $attn \n
From: $visitor ($visitormail)\n
Childs Name: $childsname \n
Childs Age: $childsage \n
Address: $address \n
Address2: $address2 \n
City: $city \n
State: $state \n
Zip: $zip \n
Class1: $class1 \n
Class2: $class2 \n
Daytime Phone: $dayphone \n
Evening Phone: $evephone \n
Message: $notes \n

$from = "From: $visitormail\r\n";

mail("info@shelburneartcenter.org", $subject, $message, $from);


Who is Participating?
nizsmoConnect With a Mentor DeveloperCommented:
A simple example which shows where to put subject and sender email address:

$email = $_GET['email'] ;
$message = $_GET['message'] ;

// This is the important line below
mail( "yourname@example.com", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";

For a simple tutorial and more examples and explanation, go here:

Let me know how you get on.
DeeEmmConnect With a Mentor Commented:
You can check if the mail has been sent correctly and then show the info you require by replacing the line

mail("info@shelburneartcenter.org", $subject, $message, $from);


if (@mail("info@shelburneartcenter.org", $subject, $message, $from);) {
       echo "<h2>Your message has been sent</h2><br>\n";
       echo "<h2>Message sent by - " . $from . "</h2><br>\n";
       echo "<h2>Message subject - " . $subject . "</h2><br>\n";
} else {
       echo "<h2>Sorry, there has been a problem, your message has not been sent</h2><br>\n";
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.