I'm using a script to create an email message, but for some reason, it can't read the variables... Now, this isnt ordinary php syntax, because in the example I got it from, they used code like this:
$messageproper =
"New message:\n" .
" \n" .
"Full name: $fullname\n" .
"Email: $email\n" ;
Now, I tried this:
$messageproper =
"New placed order:\n".
"\n".
"Ticket type: $orderdata['tickettype']\n".
"From: $orderdata['from']\n".
"To: $orderdata['to']\n";
But for some reason it gives errors in every line. So I tried this:
$messageproper =
"New placed order:\n".
"\n".
"Ticket type: ".$orderdata['tickettype']."\n".
"From: ".$orderdata['from']."\n".
"To: ".$orderdata['to']."\n";
But for some reason that just leaves every variable empty.
Because Im using a function processOrder() (where I declare and set all the variables) and sendOrder() (where I assemble the email), I already tried making the $orderdata array global, but that didn't work either.
This is the important part of the script that sends the email:
$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
// ---------------------------- preparing the headers ----------------------------
$headers =
"From: \"$fullname\" <$email>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" .
$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
// ---------------------------- sending the email ----------------------------
if ($use_envsender) {
mail($mailto, $subject, $messageproper, $headers, $envsender );
}
else {
mail($mailto, $subject, $messageproper, $headers );
}
header( "Location: $thankyouurl" );
exit ;
What could I be doing wrong here? Also, could someone explain to me what kind of syntax this is, for the $messageproper ? I've never seen such unlogic syntax before (however, now I think of it, I do: in MySQL queries, where you put a php variable in the request.)