สอบถามปัญหาการเปรียบตัวแปร php ในฟังก์ชั่นของ script ครับ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบถามปัญหาการเปรียบตัวแปร php ในฟังก์ชั่นของ script ครับ
สอบถามปัญหาการเปรียบตัวแปร php ในฟังก์ชั่นของ script ครับ
Copy
<?php
SESSION_START();
require_once('config.php');
require_once('class/class.upload.php') ;
if(isset($_GET["po_code"]))
{
$strPOC = $_GET["po_code"];
}
$result = " SELECT * FROM pocollect WHERE po_code = '".$strPOC."' ";
$query = mysqli_query($conn,$result) or die($conn->error.'<br>'.$result);
$fetch = mysqli_fetch_array($query,MYSQLI_ASSOC);
$PO = $fetch['po_code'];
$subt = $fetch['po_subt'];
$tax = $fetch['po_tax'];
$amount = $fetch['po_ttamount'];
$word = $fetch['po_amountword'];
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui.css">
<title>Purchase order</title>
</head>
<body>
<form action="" name="form1" method="post">
<div align="center"><table width="90%" border="0" >
<tr>
<td><div align="right">Sub total : <?php echo $subt; ?> </div></td>
</tr>
<tr>
<td><div align="right"> Value added TAX 7% : <?php echo $tax; ?></td>
</tr>
<tr>
<td><div align="right">Total amount THB : <?php echo $amount; ?></td>
</tr>
<tr>
<td><div align="right"><?php echo $word; ?> bath</div></td>
</tr>
</table>
<br></br>
<div align="center">
<input type="submit" name="MM_insert" onClick="MM_popupMsg('Approve success'),checkmail()" value="Approve" />
<input type="submit" name="M_insert" onClick="MM_popupMsg('Reject success'),Mail2()" value="Reject" />
</p></div>
</form>
<script>
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Approve")) {
if($amount > 5001){
$sql = " UPDATE pocollect SET
po_status = '2'
WHERE po_code = '".$PO."' ";
mysqli_query($conn,$sql) or die($conn->error.'<br>'.$sql);
}
else{
$sql = " UPDATE pocollect SET
po_status = '20'
WHERE po_code = '".$PO."' ";
mysqli_query($conn,$sql) or die($conn->error.'<br>'.$sql);
}
}
?>
</script>
<script>
function checkmail()
{
var amount = parseInt("<?= $amount ?>");
if(amount > 5000){
Mail();
}
return;
}
</script>
<script>
function Mail() //email form
<?php
if (isset($_POST['MM_insert'])){
require_once("/PHPMailer/src/PHPMailer.php");
require_once("/PHPMailer/src/SMTP.php");
$mail = new PHPMailerPHPMailerPHPMailer();
$mail->IsHTML(true);
$mail->SMTPDebug =2;
$mail->IsSMTP();
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = ""; // sets the prefix to the servier
$mail->Host = "xxxx.co.th";
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]";
$mail->Password = "tcpn7897";
$mail->From = "[email protected]";// "[email protected]";
$mail->FromName = "From System"; // set from Name
$mail->Subject = "Approve";
$mail->Body = "Approve http://192.168.101.113:85/test/PO_TABLE_2.php " ;
$email = "[email protected]" ;
$mail->AddAddress("$email"); // to Address
$mail->send();
}
?>
</script>
<script>
function Mail2() //email form
<?php
if (isset($_POST['M_insert'])){
require_once("/PHPMailer/src/PHPMailer.php");
require_once("/PHPMailer/src/SMTP.php");
$mail = new PHPMailerPHPMailerPHPMailer();
$mail->IsHTML(true);
$mail->SMTPDebug =2;
$mail->IsSMTP();
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = ""; // sets the prefix to the servier
$mail->Host = "xxxx.co.th";
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]";
$mail->Password = "tcpn7897";
$mail->From = "[email protected]";// "[email protected]";
$mail->FromName = "From System"; // set from Name
$mail->Subject = "Reject";
$mail->Body = " Your order have been rejected " ;
$email = "[email protected]" ;
$mail->AddAddress("$email"); // to Address
$mail->send();
}
?>
</script>
<script type="text/javascript">
function MM_popupMsg(msg) { //v1.0
alert(msg);
window.close();
}
</script>
</body>
</html>
จากโค้ดถ้ากด approove ไม่ว่าจะกรณีไหน เมลก็ถูกเรียกใช้งานตลอดเลยครับผมอยากให้มันส่งเมลก็ต่อเมื่อเข้าเงื่อนไข
amount > 5000
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ