查看文件: ch_passwd.php
大小: 2.94 KB
类型: application/octet-stream
<? require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php $write='N'; if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { if($_POST['passwd2']==""){ $write='S'; } if ($write=='N'){ if($_POST['passwd2']<>$_POST['passwd2']){ $write='H'; } } if ($write=='N'){ mysql_select_db($database_BE2, $BE2); $query_Rt3 = sprintf("SELECT * FROM `user` WHERE id = %s", $_SESSION['login_id']); $Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error()); $row_Rt3 = mysql_fetch_assoc($Rt3); if ($_POST['passwd1']<>$row_Rt3['passwd']){ $write='C'; } mysql_free_result($Rt3); } if ($write=='N'){ $updateSQL = sprintf("UPDATE user SET passwd=%s WHERE id=%s", GetSQLValueString($_POST['passwd2'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); $write='Y'; } } mysql_select_db($database_BE2, $BE2); $query_Rt2 = sprintf("SELECT * FROM `user` WHERE id = %s", $_SESSION['login_id']); $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); ?> <? if($write<>'N'){ echo "<SCRIPT LANGUAGE='javascript'>"; if($write=='C'){ echo "alert('您的舊密碼輸入錯誤...');";} else if($write=='S'){ echo "alert('新密碼不可空白...');";} else if($write=='H'){ echo "alert('新密碼不吻合錯誤...');";} else { echo "alert('密碼已更新...');";} echo "</SCRIPT>"; } ?> <form method="post" name="form1" action=""> <table border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#6699FF"> <tr valign="baseline"> <td colspan="2" align="center" nowrap><h2>更換密碼</h2></td> </tr> <tr valign="baseline"> <td width="99" align="center" nowrap>姓名/ID:</td> <td width="230"><input name="name" type="text" value="<?php echo $row_Rt2['name']; ?>" size="20" maxlength="12" readonly=""></td> </tr> <tr valign="baseline"> <td nowrap align="center">舊密碼:</td> <td><input name="passwd1" type="password" id="passwd1" size="20" maxlength="12" /></td> </tr> <tr valign="baseline"> <td nowrap align="center">新密碼:</td> <td><input name="passwd2" type="password" size="20" maxlength="12" /></td> </tr> <tr valign="baseline"> <td nowrap align="center">再確定新密碼:</td> <td><input name="passwd3" type="password" id="passwd3" size="20" maxlength="12" /></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="更新記錄"></td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="id" value="<?php echo $row_Rt2['id']; ?>"> </form> <?php mysql_free_result($Rt2); ?>
保存
取消
返回文件列表