|
 |
|
ทำไมใช้ javascript:history.back()'; แล้วกลับมาหน้าเดิมให้ค่าคงอยู่ ไม่ได้อ้ะค้ะ |
|
 |
|
|
 |
 |
|
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>..:::ระบบจัดการกลุ่มออมทรัพย์เพื่อการผลิต:::..</title>
</head>
<body>
<?
include "connect.php";
$uID = $_GET["uID"];
//echo "<br>";
$loan_can = $_POST["loan_can"] ;
//echo "<br>";
//echo $money;
$loan_amount = $_POST["txtloan_amount"] ;
//echo "<br>";
//echo $loan_amount;
$guarantor1 = $_POST["txtguarantor1"] ;
//echo "<br>";
//echo $guarantor1;
$guarantor2 = $_POST["txtguarantor2"] ;
//echo "<br>";
//echo $guarantor2;
?>
<?
$strSQL4 = "SELECT * FROM user WHERE user_id = '$guarantor1' " ;
$objQuery4 = mysql_query($strSQL4) or die ("Error Query [".$strSQL4."]");
while($objResult4 = mysql_fetch_array($objQuery4))
{
$dep_total1 = $objResult4["dep_total"];
}
//echo "<BR>". $dep_total1;
//echo $loan;
$strSQL5 = "SELECT * FROM user WHERE user_id = '$guarantor2' " ;
$objQuery5 = mysql_query($strSQL5) or die ("Error Query [".$strSQL5."]");
while($objResult5 = mysql_fetch_array($objQuery5))
{
$dep_total2 = $objResult5["dep_total"];
}
//echo "<BR>". $dep_total2;
$TRUE=$dep_total1+$dep_total2+$loan_can;
//echo "<br>".$TRUE ;
if($TRUE < $loan_amount){
//echo "<script>alert('วงเงินไม่เพียงพอต่อการกู้');</script>";
//echo "<script>history.back()</script>";
echo"<script>alert('วงเงินไม่เพียงพอต่อการกู้!');window.location='javascript:history.back()';</script>";
//echo "<meta http-equiv='refresh' content='0; url=loanformadd.php?uID=$user_id'>";
}else{
//echo "Y";
$dateC = date('Y') + 543;
$strSQL3 = "SELECT * FROM rateloan WHERE loa_year = '$dateC'" ;
$objQuery3 = mysql_query($strSQL3);
$n=mysql_num_rows($objQuery3);
//echo $nn;
while($row3=mysql_fetch_array($objQuery3)){
$interest = $row3["loa_name"];
$loa_year = $row3["loa_year"];
}
$loan = ($_POST['txtloan_amount'] * $interest)+ $_POST['txtloan_amount'];
$loan1 = $loan/$_POST['txtcapital'];
$_POST['txtloan_date_req'];
$_POST['txtcapital'];
$_POST['txtloa_name'];
$date_pay = date('Y-m-d',strtotime('+1 month'))."<br>";
$year = date('Y');
$month1 = date('m');
$month = (int)$month1;
$strSQL= "INSERT INTO Req_loan(loan_id,user_id,objectloan,loan_date_req,loan_date_submit,loan_amount,loan_mount,loan_mount1,interest,capital,
capital1,capital_mount,guarantor1,guarantor2,status_loan,loan_date_pay,year,month)
VALUES('".$_POST['loan_id']."','".$_POST['user_id']."','".$_POST['txtobjectloan']."',CURDATE(),'ยังไม่ได้ทำสัญญา', '".$_POST['txtloan_amount']."','$loan',$loan,'$interest','".$_POST['txtcapital']."','','$loan1',
'".$_POST['txtguarantor1']."','".$_POST['txtguarantor2']."','1','$date_pay','$year','$month')";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$strSQL2 = "UPDATE user SET ";
$strSQL2 .="status_loan1 = '1' ";
$strSQL2 .="WHERE user_id = '".$_GET["uID"]."' ";
$objQuery2 = mysql_query($strSQL2) or die(mysql_error());
if($objQuery2)
{
echo "<script>alert('บันทึกเรียบร้อยแล้ว');</script>";
echo "<meta http-equiv='refresh' content='0; url=loan.php?uID=$user_id'>";
}
}
mysql_close($objConnect);
?>
</body>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2012-04-28 09:29:29 |
By :
lookpla26 |
View :
6138 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำให้ใช้คำสั่งนี้นะครับ top.location("URL");
ส่วน history.back(); นั้นมันจะจำจากค่าที่มาก่อนหน้านี้ 1 ค่า แล้วกลับไปยังหน้านั้น แต่ถ้าไม่ผ่านหรือไม่ได้ทำการเปิดหน้าอื่นมาก่อน ก็ไม่ย้อนกลับครับ
|
 |
 |
 |
 |
Date :
2012-04-28 11:16:15 |
By :
thethaicom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|