Jump to content

complex sendmail query


robcrozier

Recommended Posts

ok, im trying to send an automated email to both me and webuser upon successful order completion. However the $message part has to contain if statements and later on for loops. Heres an example of what iv'e got so far.


[code]
$message = "
Order Number : ".$_SESSION['order_no']."
Order Date : ".date("F jS, Y")."
Development time guaranteed : ".
if ($_SESSION['e_commerce_check'] == 'yes')
{
echo ($_SESSION['turnaround_time+e-com']);
}
else
{
echo ($_SESSION['turnaround_time']);
}
." Days

Name : ".$_SESSION['name']."
Address : ".$_SESSION['address1']."
[/code]

then i'll obviously include the variable $message in the sendmail statement :

[code]
mail($to, $subject, $message);
[/code]

though when ran - it does not allow the first 'if' statement, i did expect this like as it is being used within a variable initialisation.  However does anyone have any siggestions as to how i can get round it.

Cheers!
Link to comment
Share on other sites

Why not calculate the $_SESSION bit before into a different variable:
[code]
if ($_SESSION['e_commerce_check'] == 'yes') {
$check = ($_SESSION['turnaround_time+e-com']);
} else {
$check = ($_SESSION['turnaround_time']);
}
$message = "
Order Number : ".$_SESSION['order_no']."
Order Date : ".date("F jS, Y")."
Development time guaranteed : ".$check." Days

Name : ".$_SESSION['name']."
Address : ".$_SESSION['address1'].";[/code]

Or have I not understood the question?
Link to comment
Share on other sites

Yeah that's sorted that 1 out mate cheers, why did i not think of that. lol.
Anyway i wonder if you could help me with a for loop in the same situation. Same code as above but replace the if else block with a for loop which pulls a value out of an array at each pass.  The array value will be stored in a variable like so:

[code]
$variable = $_SESSION['array_value'.$i]
[/code]

The $i variable being the array counter.

There doesn't seem to be any logical way that i can think of to pull all these variables out of the array before the $message assignment.

Can you shed any light?

Thank a lot!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.