Path : /var/www/html/smart_kpp2_v2/admin/section/default/
File Upload :
Current File : /var/www/html/smart_kpp2_v2/admin/section/default/user_change_token.php

<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
//
$sql2 = "select * from system_user where person_id='$_SESSION[login_user_id]' ";
$dbquery2 = mysqli_query($connect,$sql2);
$result2 = mysqli_fetch_array($dbquery2);
$token_line = $result2['token_line'];
//

if(isset($_POST['newtoken_line'])){
$newtoken_line = trim($_POST['newtoken_line']);
//$newemail = md5($newemail);
$sql = "update system_user set token_line = '$newtoken_line' where person_id = '$_SESSION[login_user_id]' ";
$dbquery = mysqli_query($connect,$sql);
$sql=$sql = "select * from system_user where token_line = '$newtoken_line' and person_id='$_SESSION[login_user_id]' ";
$dbquery = mysqli_query($connect,$sql);
$result = mysqli_fetch_array($dbquery);
		if($result){
		echo "<script>alert('เปลี่ยน Token Line เรียบร้อยแล้ว'); document.location.href='index.php';</script>";
		exit();
		}
		else {
		echo "<script>alert('เกิดปัญหาบางอย่าง ไม่สามารถเปลี่ยน Token_Line ใหม่ได้'); document.location.href='index.php';</script>";
		exit();
		}
}
?>
<form id="frm1" name="frm1">
<table cellpadding='5' cellspacing='5' align='center' class='row2' border=0 width=50%>
	<tr><td colspan='2' align=center><br><font size='4'>เปลี่ยน Token Line</td></tr>
	<?php if($token_line >''){ ?>
	<tr><td colspan='2' align=center><font size='2'><b>Token Line เดิม คือ <font size='2' color='#FF0000'><?php echo $token_line ?></font></td></tr>
	<?php } ?>
	<?php if($token_line ==''){ ?>
	<tr><td colspan='2' align=center><font size='2'><b><font size='2' color='#FF0000'>ยังไม่มี Token ของท่านในระบบ</font></td></tr>
	<?php } ?>
	<tr>
		<td align='right'><b>Token ใหม่&nbsp;&nbsp;</td><td  align='left'><input type="text" name="newtoken_line" Size="50"/></td>
	</tr>
	<tr>
		<td align='right'><b>Token ใหม่ (อีกครั้ง)&nbsp;&nbsp;</td><td align='left'><input type="text" name="renewtoken_line" Size="50"/></td>
	</tr>
	<tr align="center"><td colspan="2" align="center"><input type="button" value="ตกลง" onclick="goto_url(1)">&nbsp;<INPUT TYPE="button" name="back" value="ย้อนกลับ" onclick="goto_url(0)"></td></tr>
</table>
</form>	

<script>
function goto_url(val){
	if(val==0){
		callfrm("./");   // page ย้อนกลับ 
	}else if(val==1){
		if(frm1.newtoken_line.value==''){
			alert('กรุณากรอก Token ใหม่ที่ต้องการ');
		}else if(frm1.renewtoken_line.value==''){
			alert('กรุณากรอกยืนยัน Token ใหม่');
		}else if(frm1.newtoken_line.value!=frm1.renewtoken_line.value){
			alert("Token สองครั้งไม่ตรงกัน");
		}else{
			callfrm("?file=user_change_token");   //page ประมวลผล
		}
	}
}

</script>