What's new

Closed Reuse password history pa help mga ser, naka limit ng 5 password pag nag 6 pwede na magamit ulit ung ibang password

Status
Not open for further replies.
Joined
Sep 11, 2018
Posts
151
Reaction
57
Points
118
Code:
  Dim rs As RecordSet
  Dim rs2 As RecordSet
  Dim rs3 As RecordSet
  Dim query As String
  Dim query2 As String
  Dim query3 As String
  Dim insert,update As String
 
  query2 = "SELECT * FROM tbl_admin_login where admin_username = '"+txtusername.Text+"' and admin_password = '"+txtpassword.Text+"' "
 
  query3 ="select c.*,a.cntr from tblpasswordhistory c,(select count(*) as cntr from tblpasswordhistory b "+_
      " where b.username = '"+txtusername.Text+"' and b.admin_id = '"+txtadminID.Text+"')a "+_
      "where username = '"+txtusername.Text+"' and admin_id = '"+txtadminID.Text+"' order by adminid asc limit 5 offset 5"
 
  query = "select c.*,a.cntr from tblpasswordhistory c,(select count(*) as cntr from tblpasswordhistory b "+_
      " where b.username = '"+txtusername.Text+"' and b.admin_id = '"+txtadminID.Text+"')a "+_
      "where username = '"+txtusername.Text+"' and admin_id = '"+txtadminID.Text+"' order by adminid desc limit 5"
 
  update = "Update tbl_admin_login set admin_password = '"+txtpassword.Text+"', "+_
      "datecreated = now()::date where admin_id = '"+txtadminID.Text+"' "
 
  insert = "INSERT INTO tblpasswordhistory(username,password,admin_id)values "+_
      "('"+txtusername.Text+"','"+txtpassword.Text+"' ,'"+txtadminID.Text+"')"
 
  rs3 = conn.SQLSelect(query3)
  rs2 = conn.SQLSelect(query2)
  rs = conn.SQLSelect(query)
 
  if txtpassword.Text = rs2.Field("admin_password").Value Then
    MsgBox "this is your current password"
    txtpassword.SetFocus
  ElseIf txtpassword.Text <> rs2.Field("admin_password").Value Then
    If rs.RecordCount > 0 Then
      do until rs.EOF
        if txtpassword.Text = rs.Field("password").Value Then
          MsgBox "This is your old Password"
          txtpassword.SetFocus
          
        ElseIf txtpassword.Text <> rs.Field("password").Value Then
          conn.SQLExecute(insert)
          conn.SQLExecute(update)
          MsgBox "Updated!"
        End If
        rs.MoveNext
      loop
      rs.Close
      
    End If
    
  ElseIf txtpassword.Text = rs3.Field("password").Value Then
    conn.SQLExecute(insert)
    conn.SQLExecute(update)
    MsgBox "UPdated na putek!!!"
  ElseIf txtpassword.Text <> rs3.Field("password").Value Then
    conn.SQLExecute(insert)
    conn.SQLExecute(update)
    MsgBox "UPdated na putek!!!"
  End If
helpmetalaga.png
 

Attachments

Status
Not open for further replies.
Back
Top