Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

Php email not sending field values

Please see the attached php email script. When I submit this form (www.mwebdev.com/stat/employment.html), I get the email successfully. However, I only get the labels, and not the field values. The php script only has a few of the first fields to this point. I will add them after I get the email working successfully. Thanks for your help in advance.
<?php
 
 
// get posted data into local variables
$EmailFrom = "website@domainhere.com";
$EmailTo = "realemailhere.com";
$Subject = "Email from Website";
$Name = Trim(stripslashes($_POST['name'])); 
$Phone = Trim(stripslashes($_POST['phone1'])); 
$Email = Trim(stripslashes($_POST['email'])); 
 
 
// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}
 
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Home Phone: ";
$Body .= $phone1;
$Body .= "\n";
$Body .= "Office Phone: ";
$Body .= $phone2;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $address;
$Body .= "\n";
$Body .= "City: ";
$Body .= $city;
$Body .= "\n";
$Body .= "State: ";
$Body .= $state;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $zip;
$Body .= "\n";
 
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
 
// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=appsent.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Open in new window

0
isaacr25
Asked:
isaacr25
  • 3
  • 2
1 Solution
 
isaacr25Author Commented:
One addition: the php script is not uploaded to the location I posted; only the form is uploaded. Thanks.
0
 
purplepomegraniteCommented:
PHP is case sensitive for variables.  See the attached.
<?php
 
 
// get posted data into local variables
$EmailFrom = "website@domainhere.com";
$EmailTo = "realemailhere.com";
$Subject = "Email from Website";
$name = Trim(stripslashes($_POST['name'])); 
$phone1 = Trim(stripslashes($_POST['phone1'])); 
$email = Trim(stripslashes($_POST['email'])); 
 
 
// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}
 
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Home Phone: ";
$Body .= $phone1;
$Body .= "\n";
$Body .= "Office Phone: ";
$Body .= $phone2;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $address;
$Body .= "\n";
$Body .= "City: ";
$Body .= $city;
$Body .= "\n";
$Body .= "State: ";
$Body .= $state;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $zip;
$Body .= "\n";
 
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
 
// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=appsent.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Open in new window

0
 
purplepomegraniteCommented:
You'll now have name, phone1, and email working.  Others you will need to add.  Just remember to check the capitalisation!
0
 
isaacr25Author Commented:
Only my labels are capitalized. As far as I can tell, my variables are lower-case. Where do you see different in the code... I can't see the difference between my code and yours. Thanks.
0
 
purplepomegraniteCommented:
Your code:
$Name = Trim(stripslashes($_POST['name']));
$Phone = Trim(stripslashes($_POST['phone1']));
$Email = Trim(stripslashes($_POST['email']));

My code:
$name = Trim(stripslashes($_POST['name']));
$phone1 = Trim(stripslashes($_POST['phone1']));
$email = Trim(stripslashes($_POST['email']));
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now