Jump to content

Change Password Function


almystersv

Recommended Posts

Hi Guys,

 

Can you let me know what I need to change in this piece of code that will only change the users password if they enter their current password correctly.

 

<?php
require "connect.php";
$empID = $_GET['empID'];
$password = $_GET['password'];
$password2 = $_GET['password2'];
$password3 = $_GET['password3'];

if(($password == $password2) || ($password3 == $_SESSION['password']))
{
	$query =  "update employee set password = '".$password2."' where empID = ".$empID;
	$result = @mysql_query($query, $connection) 
	or die ("Unable to perform query<br>$query");
	header("Location: changePasswordForm.php");
	exit();
}
else
{
	$message1 = "Unable to update Password";
	header("Location: changePasswordForm.php?message1=$message1");
	exit();
}
?>

 

Here is the form it is reading from

<?php
session_start();
if (isset($_SESSION['username']) == false){
	header("Location: login.php");
	exit();
}
require "connect.php";

$empID = $_SESSION['empID'];
$query =  "select * from employee where empID = " .$empID;
$result = @mysql_query($query, $connection) or die ("Unable to perform query<br>$query".mysql_error());
$row= mysql_fetch_array($result);
?>
<!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=iso-8859-1" />
<title>Update Password</title>
<link rel="stylesheet" type="text/css"
href="mystylelogin.css" />
</head>

<body>

<!-- BIS Portal LOGO -->
<table width="100%" border="0">
<tr>
   		<td><img src="images/BISPortal2.gif"></td>
</tr>
</table>

<div id="passForm">
<p>Change Password</p>
</div>

<form action="changePassword.php" method="get">
<table width="64%" border="0">
  <tr>
    <td width="11%"> </td>
    <td width="21%"> </td>
    <td width="32%"></td>
    <td width="36%"><input name="empID" type="hidden" value=" <?php echo $row['empID']?>" size="3" readonly="true" /></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td>Current Password: </td>
    <td><input name="password3" type="password" /></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
  
  <tr>
    <td> </td>
    <td> </td>
    <td>New Password: </td>
    <td><input name="password" type="password" /></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td>Verify New Password: </td>
    <td><input name="password2" type="password" /></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td><?php
	if(isset($_GET['message1']))
	{
		echo $_GET['message1'];
	}?></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td><div align="center">
      <input name="Save" type="submit" value="Update" />
    </div></td>
    </tr>
  
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
</table>
</form>
</body>
</html>

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/94001-change-password-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.