|
 |
|
แก้ไขรหัสผ่าน อยากให้มี massage box แสดง ตอนตรวจสอบค่า ใน text field |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php require_once('../Connections/db_conn.php'); ?>
<?php session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$user=$_SESSION['MM_Username'];
$colname_editPass = "-1";
if (isset($_GET['userName'])) {
$colname_editPass = $_GET['userName'];
}
mysql_select_db($database_db_conn, $db_conn);
$query_editPass = sprintf("SELECT * FROM tb_member WHERE userName = %s", GetSQLValueString($colname_editPass, "text"));
$editPass = mysql_query($query_editPass, $db_conn) or die(mysql_error());
$row_editPass = mysql_fetch_assoc($editPass);
$totalRows_editPass = mysql_num_rows($editPass);
?><style type="text/css">
<!--
.style13 {color: #000099; font-size: 24px; }
.style15 {font-family: "DSN ArKorn"; font-size: 24px; color: #000099; }
.style16 {color: #CC0066}
.style17 {font-family: "DSN ArKorn"; font-size: 24px; color: #CC0066; }
.style18 {color: #0000FF}
.style19 {color: #0000FF; font-size: 24px; }
.style3 {font-family: "DSN ArKorn"; font-size: 24px; color: #0000FF; }
.style8 {font-family: "DSN ArKorn"; color: #FF0000; font-size: 24px; }
-->
</style>
<?php
if(isset($_POST['editPass'])){
$oldPass=(md5($_POST['oldPass']));
$newPass=(md5($_POST['newPass']));
$newPass2=(md5($_POST['newPass2']));
if($oldPass ==""){
echo "ใส่รหัสเดิมด้วยครับ";
}else if($newPass!=$newPass2){
echo "รหัสไม่ตรงกัน";
}else{
$result=mysql_query("UPDATE tb_member SET password='$newPass2' where userName='$user' ") or die(mysql_error());
mysql_close();
if($result){
echo "เปลี่ยนพาสเรียบร้อยแล้ว";
}
}
}
?>
<table width="752" border="0">
<tr>
<td width="44"> </td>
<td width="698"><span class="style8">Edit Password</span></td>
</tr>
</table>
<br />
<form id="fmEditPass" name="fmEditPass" method="post" action="<?=$_SERVER[PHP_SELF]?>">
<table width="750" border="0" align="left">
<tr>
<td width="318"><div align="right"><span class="style17">รหัสผ่านเดิม</span></div></td>
<td width="287" bgcolor="#F7F7F7" class="style3"><div align="center"><span class="style19">
<input type="password" name="oldPass" id="oldPass" value="<?=$_POST['oldPass']?>" />
</span></div></td>
<td width="131" class="style3"> </td>
</tr>
<tr>
<td><div align="right" class="style17">รหัสผ่านใหม่</div></td>
<td bgcolor="#F7F7F7" class="style3"><div align="center" class="style19">
<label></label>
<input type="password" name="newPass" id="newPass" />
</div></td>
<td class="style3"> </td>
</tr>
<tr>
<td><div align="right" class="style17">ยืนยันรหัสผ่าน</div></td>
<td bgcolor="#F7F7F7" class="style3"><div align="center" class="style19">
<label></label>
<input type="password" name="newPass2" id="newPass2" />
</div></td>
<td class="style3"> </td>
</tr>
<tr>
<td><div align="right" class="style17"></div></td>
<td bgcolor="#F7F7F7" class="style3"><div align="center" class="style19">
<label></label>
<span class="style18">
<input type="submit" name="editPass" id="save" value="save" />
</span></div></td>
<td class="style3"> </td>
</tr>
<tr>
<td> </td>
<td class="style3"><div align="center"></div></td>
<td class="style3"> </td>
</tr>
</table>
</form>
<br />
<?php
mysql_free_result($editPass);
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript

|
|
 |
 |
 |
 |
Date :
2010-10-17 00:36:20 |
By :
lengza |
View :
1054 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรงที่ Code (PHP)
echo "ใส่รหัสเดิมด้วยครับ";
Code (PHP)
echo "รหัสไม่ตรงกัน";
Code (PHP)
echo "เปลี่ยนพาสเรียบร้อยแล้ว";
|
 |
 |
 |
 |
Date :
2010-10-17 00:37:53 |
By :
lengza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
print("<script>alert(ใส่ข้อความตรงนี้');window.close();</script>");
|
 |
 |
 |
 |
Date :
2010-10-17 01:03:55 |
By :
aunjijoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|