<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
function Logout(){
document.location.href="index.php"
}
</script>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="*******"; // Database name
$tbl_name="*******"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//delete button
if ($_POST['btnchangepass'])
{
$current=$_REQUEST['txtcurrent'];
$new=$_REQUEST['txtnew'];
$verify=$_REQUEST['txtverify'];
$empnum= $_REQUEST['txtempnum'];
$sql="SELECT * FROM $tbl_name WHERE username='$empnum'";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
if ($current == $row['password'])
{
if ($new == $verify)
{
$sql = "UPDATE logindetails SET password = '" . $new . "' WHERE password = '" . $current . "'";
mysql_query($sql);
echo "Password changed.";
echo '<script type="text/javascript">window.location = "changepassword.php?empnum=' . $empnum . '" </script>';
}
else
echo "Please verify your new password.";
}
else {
echo "Wrong Password";
}
}
}
?>
<form id="form1" name="form1" method="post" action="changepassword.php">
<center>
<input type="hidden" name="txtempnum" value="<?php echo $_POST['txtempnum'] ?>" />
<table border=4 bordercolor= blue cellpadding= 2 cellspacing= 2 align="center">
<tr>
<td>Current Password</td>
<td><input name="txtcurrent" type="password" /></td>
</tr><tr>
<td>New Password</td>
<td><input name="txtnew" type="password" /></td>
</tr><tr>
<td>Verify New Password</td>
<td><input name="txtnew" type="password" /></td>
</tr><tr>
<td></td>
<td><input name="btnchangepass" type="submit" value="Change" />
<input name="btnback" type="button" value="Back" onclick="Logout()" /></td>
</tr>
</table>
</center>
</form>
</body>
</html>
When I click Change button. Nothing happens. No confirmation text that it has been updated successfully.
- Thanks in advance to all who can help me.