ขอโค๊ดการ กด Confirm Password หน่อยครับ แบบจะเปลี่ยนรหัสผ่านแล้วให้ Confirm password ให้ตรงกัน 2 ครั้งอะครับ
<?php
session_start();
$_SESSION["load"] = "3";
include('header.php');
$name = "";
$address = "";
$telphone = "";
$email = "";
$line = "";
$password = "";
$repassword = "";
$username = "";
$code_member = "";
$status = "";
$img = "";
$address1 = "";
$address2 = "";
$address3 = "";
$address4 = "";
?>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmMain.address2.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('กรุณาเลือกอำเภอ','')
frmMain.address2.options[frmMain.address2.length]= myOption
<?php
$intRows = 0;
$strSQL = "SELECT * FROM data2 order by AMPHUR_ID desc ";
$objQuery = mysqli_query($objCon,$strSQL);
$intRows = 0;
while($objResult = mysqli_fetch_array($objQuery))
{
$intRows++;
?>
x = <?php echo $intRows;?>;
mySubList = new Array();
strGroup = "<?php echo $objResult["AMPHUR_ID"];?>";
strValue = "<?php echo $objResult["AMPHUR_NAME"];?>";
strItem = "<?php echo $objResult["PROVINCE_ID"];?>";
strItem2 = "<?php echo $objResult["AMPHUR_CODE"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
mySubList[x,3] = strItem2;
if (mySubList[x,0] == SelectValue){
var myOption = new Option(mySubList[x,2], mySubList[x,1])
frmMain.address2.options[frmMain.address2.length]= myOption
}
<?php
}
?>
}
//**** List Province (Start) ***//
function ListProvince2(SelectValue)
{
//alert(SelectValue);
var cutdata = SelectValue.split("/");
frmMain.address3.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('กรุณาเลือกตำบล','')
frmMain.address3.options[frmMain.address3.length]= myOption
<?php
$intRows = 0;
$strSQL = "SELECT * FROM data3 order by DISTRICT_ID desc ";
$objQuery = mysqli_query($objCon,$strSQL);
$intRows = 0;
while($objResult = mysqli_fetch_array($objQuery))
{
$intRows++;
?>
x = <?php echo $intRows;?>;
mySubList = new Array();
strGroup = "<?php echo $objResult["DISTRICT_CODE"];?>";
strValue = "<?php echo $objResult["DISTRICT_NAME"];?>";
strItem = "<?php echo $objResult["AMPHUR_ID"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,0] == cutdata[0]){
var myOption = new Option(mySubList[x,2], mySubList[x,1])
frmMain.address3.options[frmMain.address3.length]= myOption
}
<?php
}
?>
}
//**** List Province (Start) ***//
function ListProvince3(SelectValue)
{
<?php
$intRows = 0;
$strSQL = "SELECT * FROM data4 order by id asc ";
$objQuery = mysqli_query($objCon,$strSQL);
$intRows = 0;
while($objResult = mysqli_fetch_array($objQuery))
{
$intRows++;
?>
x = <?php echo $intRows;?>;
mySubList = new Array();
strGroup = "<?php echo $objResult["district_code"];?>";
strValue = "<?php echo $objResult["zipcode"];?>";
mySubList[x,0] = strGroup;
mySubList[x,1] = strValue;
if (mySubList[x,0] == SelectValue){
document.getElementById("address4").value = mySubList[x,1];
}
<?php
}
?>
}
//**** List Province (End) ***//
</script>
<!-- page content -->
<div class="right_col" role="main" style="background-color: #F5FBFD; " >
<div class="page-title">
<div class=" ">
<div class=" col-lg-12 " style="background-color: #383838; height: 38px; margin-top: 17px; " align="right" >
<font color="#FFFFFF" size="3px" class="serif2" >
<div style="margin-top: 6px;" >
<font size="3px" color="white"> ยินดีต้องรับคุณ <?php echo $_SESSION["Fullname2"]; ?> </font> </font>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row" >
<div class=" col-lg-12 " >
<div class="x_panel" style="background-color: #FFFFFF; " >
<?php
if(empty($_GET["page"])){
$sql = "SELECT * FROM member_all Where id = '". $_SESSION["UserID2"]."' ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
$detail = $objResult["address"];
$address1 = $objResult["address1"];
$address2 = $objResult["address2"];
$address3 = $objResult["address3"];
$address4 = $objResult["address4"];
$name = $objResult["name"];
$telphone = $objResult["telphone"];
$email = $objResult["email"];
$password = $objResult["password"];
$username = $objResult["username"];
$status = $objResult["status"];
}
?>
<form role="form" name="frmMain" method="post" action="save_member_update.php" enctype="multipart/form-data" onsubmit="return validateForm()" >
<input type="hidden" name="idupdate" id="idupdate" class="form-control " value="<?php echo $_SESSION["UserID2"]; ?>" >
<div class=" "> <div class="x_content">
<div class="col-lg-7">
<label> <font size="4px" color="black"> ชื่อ-นามสกุล </font> </label>
<input type="text" name="name" id="name" class="form-control " value="<?php echo $name; ?>" autocomplete="off" required="" oninvalid="this.setCustomValidity(' กรุณาระบุ ชื่อ-นามสกุล ')" oninput="setCustomValidity('')" >
<br>
<label> <font size="4px" color="black"> บ้านเลขที่ </font> </label>
<input type="text" name="detail" id="detail" class="form-control " value="<?php echo $detail; ?>" autocomplete="off" >
<br>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label><font size="4px" color="Black"> จังหวัด </font></label>
<select class="form-control" id="address1" name="address1" required oninput="setCustomValidity('')" onChange = "ListProvince(this.value)" >
<?php
$sql = "SELECT * FROM data1 where PROVINCE_ID = '".$address1."' order by PROVINCE_ID asc ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
?>
<option value="<?php echo $objResult["PROVINCE_ID"]; ?>"><?php echo $objResult["PROVINCE_NAME"]; ?></option>
<?php
$i++;
}
?>
<?php
$sql = "SELECT * FROM data1 where PROVINCE_ID != '".$address1."' order by PROVINCE_ID asc ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
?>
<option value="<?php echo $objResult["PROVINCE_ID"]; ?>"><?php echo $objResult["PROVINCE_NAME"]; ?></option>
<?php
$i++;
}
?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label><font size="4px" color="Black"> อำเภอ </font></label>
<select class="form-control" id="address2" name="address2" required onChange = "ListProvince2(this.value)" >
<?php
$sql = "SELECT * FROM data2 where PROVINCE_ID = '".$address1."'
and AMPHUR_ID = '".$address2."' order by AMPHUR_ID asc ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
?>
<option value="<?php echo $objResult["AMPHUR_ID"]; ?>"><?php echo $objResult["AMPHUR_NAME"]; ?></option>
<?php
$i++;
}
?>
<?php
$sql = "SELECT * FROM data2 where PROVINCE_ID = '".$address1."'
and AMPHUR_ID != '".$address2."' order by AMPHUR_ID asc ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
?>
<option value="<?php echo $objResult["AMPHUR_ID"]; ?>"><?php echo $objResult["AMPHUR_NAME"]; ?></option>
<?php
$i++;
}
?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label><font size="4px" color="Black"> ตำบล </font></label>
<select class="form-control" id="address3" name="address3" onChange = "ListProvince3(this.value)" required >
<?php
$sql = "SELECT * FROM data3 where PROVINCE_ID = '".$address1."'
and AMPHUR_ID = '".$address2."' and DISTRICT_CODE = '".$address3."' order by DISTRICT_ID asc ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
?>
<option value="<?php echo $objResult["DISTRICT_CODE"]; ?>"><?php echo $objResult["DISTRICT_NAME"]; ?></option>
<?php
$i++;
}
?>
<?php
$sql = "SELECT * FROM data3 where PROVINCE_ID = '".$address1."'
and AMPHUR_ID = '".$address2."' and DISTRICT_CODE != '".$address3."' order by DISTRICT_ID asc ";
$query = mysqli_query($objCon,$sql);
while($objResult = mysqli_fetch_array($query))
{
?>
<option value="<?php echo $objResult["DISTRICT_CODE"]; ?>"><?php echo $objResult["DISTRICT_NAME"]; ?></option>
<?php
$i++;
}
?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label><font size="4px" color="Black"> รหัสไปรษณีย์ </font></label>
<input type="text" name="address4" id="address4" class="form-control input-sm" value="<?php echo $address4; ?>" readonly >
</div>
</div>
</div>
<br>
<label> <font size="4px" color="black"> เบอร์โทร </font> </label>
<input type="number" name="telphone" id="telphone" class="form-control " value="<?php echo $telphone; ?>" autocomplete="off" >
<br>
<label> <font size="4px" color="black"> Email </font> </label>
<input type="email" name="email" id="email" class="form-control " value="<?php echo $email; ?>" autocomplete="off" >
<br>
<label> <font size="4px" color="red"> * Username </font> </label>
<input type="text" name="username" id="username" class="form-control " value="<?php echo $username; ?>" autocomplete="off" required="" oninvalid="this.setCustomValidity(' กรุณาระบุ username ')" oninput="setCustomValidity('')" readonly >
<br>
<label> <font size="4px" color="red"> * กรุณากรอกรหัสผ่านเดิม </font> </label>
<input type="hidden" name="passwordchk" id="passwordchk" class="form-control " value="<?php echo $password; ?>" autocomplete="off" required="" oninvalid="this.setCustomValidity(' กรุณาระบุ password ')" oninput="setCustomValidity('')" >
<input type="password" name="passwordold" id="passwordold" class="form-control " value="" autocomplete="off" required="" oninvalid="this.setCustomValidity(' กรุณาระบุ password ')" oninput="setCustomValidity('')" >
<br>
<label> <font size="4px" color="red"> * ตั้งค่า รหัสผ่าน ใหม่ (กรุณากรอกขั้นต่ำ 6 ตัวอักษร) </font> </label>
<input type="password" name="password" id="password" class="form-control " value="" autocomplete="off" required="" oninvalid="this.setCustomValidity(' กรุณาระบุ password ')" oninput="setCustomValidity('')" >
<br>
<div align="left">
<button type="submit" class="btn btn-primary" style="background-color: #FFB000; border-radius: 5px; width: 110px; border-color: white; "> <font color="white" size="3px" class="serif"> บันทึก </font> </button>
<a href="member">
<button type="button" class="btn btn-danger" style="background-color: #FFFFFF; border-radius: 5px; width: 100px; border-color: white; border: 1px solid #000000; "> <font color="black" size="3px" class="serif"> ยกเลิก </font> </button>
</a>
</div>
</div>
</div>
</div>
</form>
<?php } ?>
<br><br><br>
</div>
</div>
</div>
</div>
<script>
function validateForm() {
var x1 = document.getElementById("passwordchk").value;
var x2 = document.getElementById("passwordold").value;
var x3 = document.getElementById("password").value;
var chkx1 = x1.length;
var chkx2 = x2.length;
var chkx3 = x3.length;
if (chkx2 < 6) {
alert(" กรุณากรอก Password เดิม มากกว่าหรือเท่ากับ 6 ตัวอักษร ");
return false;
}
if (chkx3 < 6) {
alert(" กรุณากรอก Password ใหม่ มากกว่าหรือเท่ากับ 6 ตัวอักษร ");
return false;
}
if (x1 != x2) {
alert(" Password เดิม ไม่ตรงกับ Password ที่ตั้งไว้ก่อนหน้า ");
return false;
}
}
</script>
<?php
include('footer.php');
?>Tag : PHP
Date :
2021-12-10 01:09:21
By :
bankmataza
View :
563
Reply :
1
https://jqueryvalidation.org/equalTo-method/
Date :
2021-12-10 14:00:08
By :
Guest
Load balance : Server 02