SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

  2. #2
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryoka012 View Post
    Anyone can help me out..
    Not unless you post your code and table structure.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is the page where is must first view my page to be update.
    Code PHP:
    <?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
    Code PHP:
     
    <?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);
    }
    ?>

  4. #4
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...^_V

  6. #6
    SitePoint Enthusiast derokorian's Avatar
    Join Date
    Jan 2011
    Location
    Ohio
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think I understand what the problem is... is it that the original password doesn't show when you edit?

  7. #7
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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..

  8. #8
    SitePoint Enthusiast derokorian's Avatar
    Join Date
    Jan 2011
    Location
    Ohio
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  10. #10
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah...Ok thanks for the reply..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •