GeneratePostID

Two functions to generate ID that is unique (not found in database)
GenerateUserID_UserKey() will actually generate two keys, both not found in database.
Needs DB_Read1Row function as well as expects to have SQL Select statements already defined (SQLUser_8 and SQLAdmin_10)
They are like
SQLUser_8 = "Select * From  " & DBTable1 & " Where UserID = N'{{$ID$}}' Or UserSecretKey = N'{{$SE$}}' "
SQLAdmin_10 = "Select * From  " & DBTable5 & " {{$WH$}} "


Public

Tested

My Own Work
Function GenerateUserID_UserKey()
 Do
  Randomize Timer
  UserRandID   = GetRandom(6, 9, 1, 1, 0, 0, "")
  UserSecKey   = GetRandom(20, 40, 1, 1, 1, 0, "") ' Make sure UserID and UserSecKey are unique
  SqlCmd    = Replace(SQLUser_8, "{{$ID$}}", UserRandID)
  SqlCmd    = Replace(SqlCmd, "{{$SE$}}", UserSecKey)
  DB1Record   = DB_Read1Row(SqlCmd, SepaCol)
  If DB1Record = "" Then Exit Do
 Loop
 GenerateUserID_UserKey = UserRandID & SepaCol & UserSecKey
End Function

Function GeneratePostID()
 Do
  Randomize Timer
  UserRandID   = GetRandom(3, 3, 0, 1, 0, 0, "") & GetRandom(4, 8, 1, 0, 0, 0, "") ' Make sure UserID and UserSecKey are unique
  SqlCmd    = Replace(SQLAdmin_10, "{{$WH$}}", "Where PostID = '" & UserRandID & "'")
  DB1Record   = DB_Read1Row(SqlCmd, SepaCol)
  If DB1Record = "" Then Exit Do
 Loop
 GeneratePostID   = UserRandID
End Function

None

Views 172 Downloads 39

Classic ASP Protection
ANmarAmdeen
674
Revisions

v2.0