0
<!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.

4
Contributors
3
Replies
6
Views
6 Years
Discussion Span
Last Post by ko ko
0

<form id="form1" name="form1" method="post" action="changepassword.php">
Where is this file?
1. your code is a bit cluttered
2. Dont use REQUEST! Use explicitly either POST or GET
3. Instead of

mysql_connect("$host", "$username", "$password")or die("cannot connect");

use

mysql_connect("$host", "$username", "$password")or die("Error:" .mysql_error());

and post error message you get!

Edited by Stefano Mtangoo: n/a

0

<form id="form1" name="form1" method="post" action="changepassword.php">

What for that file ? You've all the snippets for that process in the same file. Is not it ?
Perhaps, your problem due to

<form id="form1" name="form1" method="post" [B]action="changepassword.php"[/B]>

How is it with this one:

<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.