Upadting data and then sned mail if certain field equal to c

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mehidy
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Oct 01, 2012 9:50 pm

Upadting data and then sned mail if certain field equal to c

Postby mehidy » Mon Oct 01, 2012 10:31 pm

Hi

I am using belo scrip to update my data & its working fine. But i need to send auto mail after updating the data.
Here is my code


Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...onal.dtd"><html xmlns="http://www.w3.org/19...9/xhtml"><head>
<style type="text/css">

body {
margin:50px 0px; padding:0px;
text-align:center;
font:13px Tahoma,Geneva,sans-serif
}

#content {
width:1200px;
margin:0px auto;
text-align:left;
padding:15px;
border:0px dashed #333;
background-color:#eee;
}
</style>
<link rel="icon" href="http://www.mysite.co...om/favicon.ico" type="image/vnd.microsoft.icon" />
</head>
<body>
<div id='content'><h3><center>Success! </center></h3> 
<table width='100%' border='0' cellspacing='1' cellpadding='0'>
<tr>
<td>
<table width='100%' border='0' cellspacing='1' cellpadding='1'>
<tr>

<td align='center'><strong>ID</strong></td>
<td align='center'><strong>SAMPLE TYPE</strong></td>
<td align='center'><strong>SAMPLE SIZE</strong></td>
<td align='center'><strong>SAMPLE COLOR</strong></td>
<td align='center'><strong>SAMPLE QTY</strong></td>
<td align='center'><strong>SUB NO</strong></td>
<td align='center'><strong>RTS/TTS</strong></td>
<td align='center'><strong>SENT ON</strong></td>
<td align='center'><strong>C.RCV ON</strong></td>
<td align='center'><strong>COMMENTS</strong></td>
<td align='center'><strong>REMARKS</strong></td>
</tr>
<?php
error_reporting(0);
require("connect.php");
// find out how many records there are to update
$size = count($_POST['tbl_smpl_id']);

// start a loop in order to update each record
$i = 0;
while ($i < $size) {
// define each variable
$tbl_smpl_id = $_POST['tbl_smpl_id'][$i];
$smpl_typ = $_POST['smpl_typ'][$i];
$smpl_size = $_POST['smpl_size'][$i];
$smpl_col = $_POST['smpl_col'][$i];
$smpl_qty = $_POST['smpl_qty'][$i];
$smpl_subno = $_POST['smpl_subno'][$i];
$smpl_rtstts = $_POST['smpl_rtstts'][$i];
$smpl_senton = $_POST['smpl_senton'][$i];
$cmnts_rcvon = $_POST['cmnts_rcvon'][$i];
$smpl_cmnts = $_POST['smpl_cmnts'][$i];
$smpl_rmks = $_POST['smpl_rmks'][$i];

// do the update and print out some info just to provide some visual feedback

$query = "UPDATE `tbl_smpl` SET
`smpl_typ` = '$smpl_typ',
`smpl_size` = '$smpl_size',
`smpl_col` = '$smpl_col',
`smpl_qty` = '$smpl_qty',
`smpl_subno` = '$smpl_subno',
`smpl_senton` = '$smpl_senton',
`cmnts_rcvon` = '$cmnts_rcvon',
`smpl_cmnts` = '$smpl_cmnts',
`smpl_rmks` = '$smpl_rmks',
`smpl_rtstts` = '$smpl_rtstts'
WHERE `tbl_smpl_id` = '$tbl_smpl_id' LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
print "

<tr>
<td align='center'><p>$tbl_smpl_id</p></td>
<td align='center'>$smpl_typ</td>
<td align='center'>$smpl_size</td>
<td align='center'>$smpl_col</td>
<td align='center'>$smpl_qty</td>
<td align='center'>$smpl_subno</td>
<td align='center'>$smpl_rtstts</td>
<td align='center'>$smpl_senton</td>
<td align='center'>$cmnts_rcvon</td>
<td align='center'>$smpl_cmnts</td>
<td align='center'>$smpl_rmks</td>
</tr>
";
++$i;
}
mysql_close();
?> 
<tr>
<td colspan='13' align='center'>
<input value="HOME" type="button" onclick="window.location.href='dano.php'">
<input value="GO2 ALL VIEW" type="button" onclick="window.location.href='vod0011.php'">
<input value="del" type="button" onclick="window.location.href='ddcolupdateano.php?col_tbl_order_id=<?php echo $id; ?>'">
</td>
</tr>
</table>
</td>
</tr>

</table>
</div>
</body>
</html>

My requiremnet is, if $smpl_typ=pps and $smpl_cmnts=Approved then it will send auto mail to the user.
Kindly advise any suggestion or any example to achive my requirement.

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Upadting data and then sned mail if certain field equal

Postby seandisanti » Tue Oct 02, 2012 8:09 am

My requiremnet is, if $smpl_typ=pps and $smpl_cmnts=Approved then it will send auto mail to the user.
Kindly advise any suggestion or any example to achive my requirement.


something like...

Code: Select all

 if ($smpl_typ='pps' && $smpl_cmnts='Approved') {
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('caffeinated@example.com', 'My Subject', $message);
}

that's just the conditions you've already stated and the first example from php.net for mail()


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest