Email Alert For Stock Less

Codes here !

Moderators: macek, egami, gesf

shaz
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Jan 27, 2013 5:17 pm

Email Alert For Stock Less

Postby shaz » Sun Jan 27, 2013 5:54 pm

Hi all,
Please help me on how to get email alert for admin when stock less than 3.
The admin will get automaticly email notification in his mailbox.
Anyone who know about this?

Thank you.

shaz
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Jan 27, 2013 5:17 pm

Re: Email Alert For Stock Less

Postby shaz » Tue Jan 29, 2013 11:04 pm

Anyone can help me regarding this question.
There is my coding.

<?php
error_reporting(E_ALL ^ E_NOTICE);
//select all data from table 'accessories_update'
$record = mysql_query("SELECT InStock FROM accessories_update") or die(mysql_error());

//select total number of row from the previous record
$total = mysql_fetch_row($record) or die(mysql_error());

//select all data form first row from the record
$data = mysql_fetch_array($record);

//coding check whether stock less than 3 (2 or less)
if( $total < 3 ) {
$to = 'wan@example.com';
$subject = 'Warning! Less stock...';
$message = 'Please add your stock! Your stock is already less than 3 right now...';
$headers = 'From: nfsmohamad@gmail.com'
. "\r\n"
. "Reply-To:wan@example.com"
. "\r\n"
. "X-Mailer: PHP/" . phpversion();
if(mail($to, $subject, $message, $headers)) {
echo "Email sent successfully!";
} else {
echo "<script>alert('Failure: Email was not sent!')</script>";
}
}
?>

Does not get error but not successful to get email alert.
Hopefully anybody can help me... :(


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 0 guests