seding mail during die along with text output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bcyork
Forum Newbie
Posts: 8
Joined: Wed Sep 17, 2008 11:42 am

seding mail during die along with text output

Post by bcyork »

Is it possible to send an email during a die function along with the text output to the user. I have a script that I use for clients to download files to hide the directory structure to get to them. However out of human error or a weird email client that messes up the link users won't get directed to the file. In the script there is a check for that. If the file doesn't exist then it goes to die and spits out a message. Is it possible to send me an email notifying me?

Thanks!
Brian
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: seding mail during die along with text output

Post by AbraCadaver »

Sure, post some code.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
bcyork
Forum Newbie
Posts: 8
Joined: Wed Sep 17, 2008 11:42 am

Re: seding mail during die along with text output

Post by bcyork »

Code: Select all

if(!file_exists($file)) die("The file doesn't seem to exist.");
Is it possible to put in the die () an aditional php script to send an email along with the message?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: seding mail during die along with text output

Post by AbraCadaver »

bcyork wrote:

Code: Select all

if(!file_exists($file)) die("The file doesn't seem to exist.");
Is it possible to put in the die () an aditional php script to send an email along with the message?
Just put it in the if:

Code: Select all

if(!file_exists($file)) {
   mail('me@example.com', 'file not found', $file . ' was not found, blah, blah');
   die("The file doesn't seem to exist.");
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
bcyork
Forum Newbie
Posts: 8
Joined: Wed Sep 17, 2008 11:42 am

Re: seding mail during die along with text output

Post by bcyork »

Thanks!
Post Reply