Phone number not displaying in confirmation email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ralphiedee
Forum Newbie
Posts: 8
Joined: Fri Jul 18, 2008 10:59 pm

Phone number not displaying in confirmation email

Post by ralphiedee »

In the confirmation Email I receive when someone uses the contact form I get all the info EXCEPT the phone number ( it is blank ) script is below

<?php

$EmailFrom = "Million-heirs.com";
$EmailTo = "admn@million-heirs.com,vze2btvh@verizon.net";
$Subject = "Million-heirs.com";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));

// 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 .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$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=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Phone number not displaying in confirmation email

Post by Celauran »

The code itself looks fine (though it would look better wrapped in syntax tags). Have you tried echoing $Tel?

On an unrelated note, this is a little pointless:

Code: Select all

$validationOK = true;
if (!$validationOK)
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Phone number not displaying in confirmation email

Post by phphelpme »

I would check to see if your name for your input matches your:

Code: Select all

$Tel = Trim(stripslashes($_POST['Tel'])); 
Is it named: Tel or tel for instance and that could be why your not getting the variable. Check your variable to see if it is empty or not. :)

Don't really know why this is used though:

Code: Select all

// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
Is there something missing from your code that we are not seeing here? ;)
Post Reply