skatermike21988 Posted May 6, 2007 Share Posted May 6, 2007 ok, I am working on a shopping cart type deal, and i am making email templates, Like a email that will be sent upon order completion. Well i want to be able to edit them in the admin area. I tried to use a mysql table but that won't work because i have variables inside the message. The variables that are inside the message won't get sent, for example: an email should send like so: Hello Mike Jones, We have successfully recieved your order for cd rom drive. The total billed today is $49.99 but using a mysql table it sends like so: Hello $first_name $last_name, We have successfully recieved your order for $description The total billed today is $amount So i reverted to making a file called mailtemplates.php which will hold all my templates. mailtemplates.php is like this: <? $pending_orders="$first_name $last_name has just submited a order though $payment and is currently pending the total for this order is: $amount and the product(s) purchased are $description"; $pending_orders_subj="A New Pending Order Has Been Submited"; ?> A page that sends: $amount=$total; $payment="paypal"; $first_name=$paypal['firstname']; $last_name=$_POST[lastname]; $description=$order_details; echo"$amount<br>$payment<br>$first_name<br>$last_name<br>$description<br>"; //SELECT THE ADMIN EMAIL TO SEND TOO $query = "SELECT * FROM admin"; $result = mysql_query($query)or die('Query failed: ' . mysql_error()); while($row = mysql_fetch_array($result)) { $adminemail = $row["email"]; include'../includes/mailtemplate.php'; //MAIL VARIABLES: $to=$adminemail; $subj=$pending_orders_subj; $mess=$pending_orders; include'../includes/mail.php'; } and mail.php is like so: <? $headers ="From: [email protected]"; mail($to,$subj,$mess,$headers); ?> Now it sends the mail with the correct data, but here is the problem. On the page to edit the template the variables don't show up, like so Here is the code to edit: <? include'../../includes/mailtemplate.php'; <table> <tr> <td> Admin Pending E-mail: </td> <td> Subject<br> <input type=text name=admin_pending_subject value="<? echo "$pending_orders_subj"; ?>"> <br> Body:<br> <textarea name="admin_pending_body"><? echo"$pending_orders";?></textarea> </tr> <tr> Now inside the text area should display: $first_name $last_name has just submited a order though $payment and is currently pending the total for this order is: $amount and the product(s) purchased are $description but instead displays has just submited a order though and is currently pending the total for this order is: and the product(s) purchased are Any idea how i can get it to display the $first_name so i can use it to edit it? Link to comment https://forums.phpfreaks.com/topic/50209-variable-help/ Share on other sites More sharing options...
benjaminbeazy Posted May 6, 2007 Share Posted May 6, 2007 the variable $message is in double quotes, which means that php will try to interpolate the variables contained within make $message a literal, i.e. single quotes and use eval on the sending page eval("\$mess = \"$pending_orders\";"); Link to comment https://forums.phpfreaks.com/topic/50209-variable-help/#findComment-246478 Share on other sites More sharing options...
skatermike21988 Posted May 6, 2007 Author Share Posted May 6, 2007 awesome works great many thanks!! Link to comment https://forums.phpfreaks.com/topic/50209-variable-help/#findComment-246481 Share on other sites More sharing options...
benjaminbeazy Posted May 6, 2007 Share Posted May 6, 2007 yep. Link to comment https://forums.phpfreaks.com/topic/50209-variable-help/#findComment-246482 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.