PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jul 05, 2020 9:31 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Feb 05, 2013 5:44 pm 
Offline
Forum Newbie

Joined: Tue Feb 05, 2013 5:35 pm
Posts: 1
I can not for the life of me figure out how to send all the variables in the email message. Here is my code:

<?php
//client variables
$name = $_POST["name"];
$title = $_POST["title"];
$ftlt = $_POST["ftlt"];
$phone = $_POST["subject"];
$mobile = $_POST["mobile"];
$street = $_POST["street"];
$city = $_POST["city"];
$zip = $_POST["zip"];
$license = $_POST["license"];
$desired = $_POST["desired"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$email = $_POST["email"];
$verif_box = $_POST["verif_box"];

$message = stripslashes($message);
$subject = stripslashes($subject);
$name = stripslashes($name);
$title = stripslashes($title);
$ftlt = stripslashes($mobile);
$phone = stripslashes($phone);
$mobile = stripslashes($mobile);
$street = stripslashes($state);
$city = stripslashes($city);
$zip = stripslashes($zip);
$license = stripslashes($license);
$desired = stripslashes($desired);

// validate verification code
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if pass send message
mail("xx@yy.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "email: $email");
// cookie deletion
setcookie('tntcon','');
} else if(isset($message) and $message!=""){
// if verif entry incorrect error message
header("Location: index.php?subject=$subject&from=$from&message=".urlencode($message)."&wrong_code=true");
exit;
} else {
echo "no variables received, this page cannot be accessed directly";
exit;
}
?>

His issue is with this line of code. How do we add the client variables to achieve proper output in the sent message?

mail("xx@yy.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "email: $email");

Would I use the "\n\nname: ".$name. for each variable?

My php coding is minimal. Any help appreciated!
Thanks!


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 6:44 pm 
Offline
Forum Contributor
User avatar

Joined: Wed Apr 14, 2010 4:45 pm
Posts: 375
Location: UK
Hi,

You need to concatenate all the form values - as an example:

Syntax: [ Download ] [ Hide ]
$message .= 'Sender: ' . $name . PHP_EOL;
 


The important point to look at in this code is the .= operator, because what this does is append any new information to that already stored in the $message variable. The PHP_EOL code is used when you're outputting the email in plaintext format (rather than HTML) to create a compatible line break - if you *are* using HTML then you can either format the different sections of the message into their own paragraphs or just add line breaks (<br> for HTML 4.1).

HTH,

Mecha Godzilla


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group