<!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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript">

function Logout(){

	$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'])
		$empnum= $_REQUEST['txtempnum'];
		$sql="SELECT * FROM $tbl_name WHERE username='$empnum'";
		$row = mysql_fetch_array($result);
		// Mysql_num_row is counting table row
		// If result matched $myusername and $mypassword, table row must be 1 row
		// 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 . "'";
				echo "Password changed.";
				echo '<script type="text/javascript">window.location = "changepassword.php?empnum=' . $empnum . '" </script>';
				echo "Please verify your new password.";
		else {
			echo "Wrong Password";


<form id="form1" name="form1" method="post" action="changepassword.php">
    	<input type="hidden" name="txtempnum" value="<?php echo $_POST['txtempnum'] ?>" />
    	<table  border=4 bordercolor= blue cellpadding= 2 cellspacing= 2 align="center">
				<td>Current Password</td>
				<td><input name="txtcurrent" type="password" /></td>
				<td>New Password</td>
				<td><input name="txtnew" type="password" /></td>
				<td>Verify New Password</td>
				<td><input name="txtnew" type="password" /></td>
                <td><input name="btnchangepass" type="submit" value="Change"  />
				<input name="btnback" type="button" value="Back" onclick="Logout()" /></td>


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.

6 Years
Discussion Span
Last Post by ko ko

<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");


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

and post error message you get!

Edited by Stefano Mtangoo: n/a


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