View Single Post
Old 05-29-2009, 02:06 PM   #4 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by code_junkie View Post
Its just the basic mailto function.
Code:
$to = "email@address.com";
$from = "email@address.com";
$subject = "Message from site";
$message = "";
$headers  = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";

ini_set('sendmail_from', $from);
mail($to, $subject, $message, $headers);
Ok, well based on that, of course it's going to run on every refresh because there's nothing stopping it from running.

If you include an IF conditional that will check for a specific status, it will only run once..

I like to base it off a hidden POST variable say, "submit_form" and set that value to true. Then on the receiving page, make sure that it is set to true, then run your mail function.

After your mail function, unset that variable, that way it won't be true anymore and then if they hit refresh, it won't send the email.
allworknoplay is offline  
Reply With Quote
The Following User Says Thank You to allworknoplay For This Useful Post:
code_junkie (05-29-2009)