What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

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


Inyakidexter09

Enthusiast
Joined
Sep 11, 2018
Messages
113
Reaction
56
Age
21
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
 

Like us on facebook

Online statistics

Members online
1,364
Guests online
1,105
Total visitors
2,469

Forum statistics

Threads
880,464
Messages
15,580,239
Members
1,407,203
Top