Jump to content

Visible Flaws in this form?


virtuexru

Recommended Posts

I made a form for users to update new passwords. Any huge security flaws here?

 

<?

include 'config.php';

include 'opendb.php';

 

  $username    = $_POST['txtUserId'];

  $oldpw        = $_POST['OldPassword'];

  $newpw      = $_POST['NEWPW1'];

  $newpwv    = $_POST['NEWPW2'];

 

  if (($newpw)!=($newpwv))

  {

      echo "Password doesn't match.";

      Die();

  }

 

  $min_length = 6;

 

  if(strlen($newpw) < $min_length)

  {

      echo "Password not long enough, minimum 6 characters.";

      Die();

  }

 

  $sql = "SELECT user_id FROM tbl_auth_user WHERE user_id = '$username' AND user_password = OLD_PASSWORD('$oldpw')";

 

  $result = mysql_query($sql) or die('Query failed. ' . mysql_error());

     

      if (mysql_num_rows($result) == 1) {

     

        $newpassword = sha1($password);

 

        $query = "UPDATE tbl_auth_user SET user_password = '$newpassword' WHERE user_id = '$username'";

     

        mysql_query($query) or die('Error, query failed');

       

        echo "Update successful";

 

  }

 

  else {

 

  echo "Old password not correct or username does not exist.";

 

  }

 

include 'closedb.php';

?>

Link to comment
Share on other sites

well only use mysql_real_escape_strings if magic quotes is disabled

(You have to run phpinfo() to find that out)

If you ever think they are going to be "output" to a browser, you need to run them through something that will clean javascript, php, and/or xhtml text.  Since it is just a username and password, you might want to clean it for specific characters, (like mysql wildcards).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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