iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-05-2004, 01:07 PM
bodgekaloopie's Avatar
WebProWorld Member
 
Join Date: Aug 2004
Location: Michigan, USA
Posts: 66
bodgekaloopie RepRank 0
Default PHP Email Syntax

Recently I had to restructure a database and split it into two tables. Since then, the mail() function that I have in one of my pages won't work properly.

The email will send, but none of the variables appear. The code is:
Code:
$body = "Company Name just received an online order from {$_POST['customer_name']}.";
mail("name@url.com", "Order Received", $body, "From: info@url2.com");
I have tried a few variations on the variable {$_POST['customer_name']} with no success.

Can anyone point me in the right direction?
Reply With Quote
  #2 (permalink)  
Old 10-05-2004, 02:53 PM
mushroom's Avatar
WebProWorld Pro
 
Join Date: Feb 2004
Location: Queen Charlotte B. C. Canada
Posts: 287
mushroom RepRank 0
Default

Compound variables always provide a syntax chalange when dealing with quotes, you can simplify the code by first turning it into a simple variable $customer_name = $_POST['customer_name']; then use it ($customer_name) in your code.
also see http://ca3.php.net/manual/en/ref.mail.php for more info on the mail function.
__________________
Irony: That for most people the most "trusted" web site on the planet is for a company the has been convicted of criminal activity.

Both Security and SuSe start with "S". www.oldslides.com
Reply With Quote
  #3 (permalink)  
Old 10-05-2004, 03:25 PM
bodgekaloopie's Avatar
WebProWorld Member
 
Join Date: Aug 2004
Location: Michigan, USA
Posts: 66
bodgekaloopie RepRank 0
Default

I checked the online resources at php.net before posting here, but will continue to research.

I tried your suggestion with no results again - added:
Code:
$lname = $_POST['lender_name'];
just before setting the $body variable with the same email results:

Quote:
Company Name just received an online order from .
Reply With Quote
  #4 (permalink)  
Old 10-05-2004, 04:22 PM
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 972
speed RepRank 1
Default

I haven't seen the rest of the code and I don't know what you've tried, but I'm assuming when the email arrives it has the line "Company Name just received an online order from" but no customer name.

Does $_POST['customer_name'] have a value set for it?

You can display your post variables by adding var_dump($_POST); to the script if customer_name is not in the list or does not have a value then that's where you need to start looking.
Reply With Quote
  #5 (permalink)  
Old 10-05-2004, 07:29 PM
WebProWorld Pro
 
Join Date: May 2004
Location: United Kingdom
Posts: 151
php~pro RepRank 0
Default

OMG whats that?

Check your other post with regards escaping. Check the escape after the word from. Also If I could recommend you used variables for things like email address and site name. These could be stored in a config file and reused sitewide. Also if your site ever changes address or you sell an application (many years away) , you can config the site from a single file.

Also when making mail dont forget to add header information.

So
config.php
<?php
$email = "email_address_here";
$site_url = "site_url_here";
?>

<?php
//call config file
include("config.php");

//make email now you have email var + any others you may need
$body = "Company Name just received an online order from ."$_POST['customer_name'];
mail("name@url.com", "Order Received", $body, "From:".$email);

?>
Untested, but should be fine. Excuse if not, just done 16 hrs coding with GD Lib and Geomapping. Heads-a-shed.
Reply With Quote
  #6 (permalink)  
Old 10-06-2004, 05:07 PM
bodgekaloopie's Avatar
WebProWorld Member
 
Join Date: Aug 2004
Location: Michigan, USA
Posts: 66
bodgekaloopie RepRank 0
Default

Thanks for all your help mushroom & php~pro. It is all working with your expert advice!
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:19 AM.



Search Engine Optimization by vBSEO 3.3.0