How to get the true value in md5 format in DB

i have a problem when in echo out the value…the value of the save md5 file is echoing out…

My Problem is when i update the user is echo out value on the database is save…
Anyone can help me out…

Not unless you post your code and table structure.

this is the page where is must first view my page to be update.


<?php
session_start();
if(isset( $_SESSION['username']));
echo "Welcome $_SESSION[username].<br>";
include_once("conn.php");
$uname=$_GET['UserName'];
$query=mssql_query("Select * FROM tblUser where UserName='$uname' ");
$d=mssql_query("Select DeptName from tblDept");
$user=mssql_query("Select * from tblUserLevel");

?>
<html>
<head>
	<title>Edit User</title>
</head>
<body>
<?php
	while ($row=mssql_fetch_array($query)) {
			$id=$row['id'];
			$dept=$row['Dept'];
			$email=$row['Email'];
			$uname=$row['UserName'];
			$fname=$row['Firstname'];
			$lname=$row['Lastname'];
			$pass=$row['Pass'];
			$userlvl=$row[UserLevel];
	}

?>
<table>
<form method='post' action='updateuser.php'>
<tr>
	<input type='hidden' value=<?php echo $uname ?> name='uname'>
	<td>User Name:</td>	
	<td><label for='uname'><?php echo $uname?></label> </td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' value=<?php echo $fname?> name='fname'></td>
</tr>
<tr>
	<td>Last Name:</td>
	<td><input type='text' value=<?php echo $lname ?> name='lname'></td>
</tr>	
<tr>
	<td>Password:</td>
	<td><input type='password' value=<?php echo $pass ?> name='pass' size='45'></td>
</tr>
<tr>
	<td>Re-Type Password:</td>
	<td><input type='password' value=<?php echo $pass ?> size='45'></td>
</tr>
<tr>
	<td>Email Address:</td>
	<td><input type='text' value=<?php echo $email ?> name='email' size='35'></td>
</tr>
<tr>
	<td> Department : </td>
	<td>
	<?php 
	echo "<select name='dept' tabindex='8'>";
	echo "<option selected >$dept</option>";
	while($row=mssql_fetch_array($d)){
	echo "<option value=$row[DeptName]>$row[DeptName]</option>";
	}echo '</select>';
	?>
	</td>
</tr>
<tr>
	<td>User Level:</td>
	<td>
	<?php 
	echo "<select name='userlevel' tabindex='8'>";
	echo "<option selected >$userlvl</option>";
	while($row=mssql_fetch_array($user)){
	echo "<option value=$row[UserLevel]>$row[UserLevel]</option>";
	}echo '</select>';
	?>
	</td>
</tr>
<tr>
	<td>
	<input type='submit' value='Save' name='save'>
	<a href='Supportviewuser.php'>Cancel</a>
	</td>
</tr>
</form>
</table>
</body>
</html>

this is the php script



<?php
session_start();
include_once("conn.php");

if(empty($_POST['pass'])){
header('location:edituser.php');
}
elseif(trim($_POST['pass']) <> trim($_POST['repass'])){
header('location:edituser.php');
}
else{
update($_POST['uname'],$_POST['fname'],$_POST['lname'],md5($_POST['pass']),$_POST['email'],$_POST['dept'],$_POST['userlevel'],$con);
header('location:viewuser.php');
}
function update($uname,$fname,$lname,$pass,$email,$dept,$userlevel,$con){
	 mssql_query("Update tblUser Set Firstname='$fname', Lastname='$lname',Pass='$pass',Email='$email',Dept='$dept',UserLevel='$userlevel' where UserName='$uname' ");
	mssql_close($con);
}
?>

Hmm, never dealt with MS’s SQL so if you don’t mind I’ll stay out of this one. Good luck though, I’m sure someone can help :wink:

ok…^_V

I dont think I understand what the problem is… is it that the original password doesn’t show when you edit?

what i mean is the md5 that is use to encrypt the password.
when i echo the password the encrypted password is echoing out.

your right derokorian the original password doesn’t show up.instead the encrypted password show up…how will i get the original not the encrypted one.

Thanks…

Well I believe md5 is one way, the only encoding I know of that can be reversed is base64_encode/base64_decode. However I do not recommend that, I belive generally better to not use reversible algorithms for passwords.

As dekorian says MD5 is one way. It’s purpose is to protect the users password from anyone including you the admin.

It’s never a good idea to echo out a users password over the internet. If they want to change it then instead ask them to confirm their current password in one box and then input it twice in two new boxes.

Ah…Ok thanks for the reply…