Avatar billede viking_sk Nybegynder
16. juli 2003 - 09:10 Der er 2 kommentarer

Username and PIN

Hello, Thanks fo help befor o "musicchart" but probably I´m not good enough to use the script he has send me. I would like to have on my page the possibility for the customers to insert the username and the PIN code and then see their prvat data from the My SQL database.I will put the data to the d-base myself so it doesn´t have to take any data from the customer only to read the exact row of the d -base - the one where he username and the PIN code is if they ae right... I would like to ask if there is anybody who could do this for me for the price which I could pay.
Thank you very much
Avatar billede rako Nybegynder
16. juli 2003 - 11:57 #1
You need a form with two form fields for the users to input their informations. The form fields must be named: "ID" and "PW". Submit the data to a file containing below code:

Dim IDform,  PWform
IDform = request.form("ID")
PWform = request.form("PW")

strSQL = "Select * from users"
Set rs = Conn.Execute(strSQL)

IF NOT (rs.BOF or rs.EOF) then

    'check the userID & PW against the database content
    Do
        IF IDform = rs("userid") and PWform = rs("pw") then

        response.write "<p>Welcome " & rs("name") & "</p>"

        rs.MoveNext
          else

        rs.MoveNext   
        End IF
    Loop While Not rs.EOF

End IF

'Close Recordset
rs.Close
Set rs = Nothing

The code is comparing the user input against the colomn's "userID" & "pw" and if the user's information is found, the name from the colomn "name" is displayed. You can add your own db-colomn as you like.

There might be a better solution, but this should indeed work...
Avatar billede dna Nybegynder
16. juli 2003 - 20:23 #2
sql = "SELECT * from users where userID = '"& request.form("ID") &"' AND '"& request.form("PW") &"'"
set record = conn.execute(sql)

if record.eof then
  Response.write "User not found"
else
  Response.write "Hey " & record("name") & " .. welcome!"
end if
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester