Newsgroup: it.comp.www.php
Titolo: da form web inserire dati in campi criptati di DB mySQL

Ciao a tutti.
Ho la mia bella tabellina di Login in MySQL, in cui i campi "userID" e
"password"
sono criptati usando la seguente stringa SQL
insert into login values
(password('sporting'),'Mario',password('annabella'),'0','0','Mario',
'Robusti');
OK fino a qui riesco a fare tutto...manualmente via client mySQL, ma il
problema nasce quando dovrei farlo nel form web.
Ovviamente il comportamento inserisci records di ultradev, lo fa senza
criptare un bel niente ed io non so dove mettere le mani. Non capisco se
devo agire nella parte di codice ASP dell'inserimento oppure in quella della
chiamata del recordset. Non penso in quest'ultima, proprio perchè è solo una
chiamata...
Quindi vi chiedo un aiuto per terminare questo mio primo progetto con ASP.
Grazie a tutti, Alen.
___________________________________
Il codice della pagina....
___________________________________
<%@LANGUAGE="VBSCRIPT"%>
<%
' *** Redirect If Session Variable Does Not Exist
' *** MagicBeat Server Behavior - 2016 - by Jag S. Sidhu - 
www.magicbeat.com
If Session("admin") = "" Then
Response.Redirect("intranet.asp")
End  If
%>
<!--#include file="Connections/connLineafitIntranet.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) <> "") Then
  MM_editConnection = MM_connLineafitIntranet_STRING
  MM_editTable = "login"
  MM_editRedirectUrl = "new_user_details.asp"
  MM_fieldsStr  =
"nome_utente|value|cocgnome_utente|value|checkbox|value|username|value|passw
ord|value|userID|value"
  MM_columnsStr =
"nomeUtente|',none,''|cognomeUtente|',none,''|amministrator|none,none,NULL|u
sername|',none,''|password|',none,''|userID|',none,''"
  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  ' set the form values
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
  Next
  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert")) <> "") Then
  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End if
    MM_tableValues = MM_tableValues & MM_columns(i)
    MM_dbValues = MM_dbValues & FormVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ")
values (" & MM_dbValues & ")"
  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If
End If
%>
<%
set rsLogin = Server.CreateObject("ADODB.Recordset")
rsLogin.ActiveConnection = MM_connLineafitIntranet_STRING
rsLogin.Source = "SELECT * FROM login"
rsLogin.CursorType = 0
rsLogin.CursorLocation = 2
rsLogin.LockType = 3
rsLogin.Open()
rsLogin_numRows = 0
%>
<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats
variables
' set the record count
rsLogin_total = rsLogin.RecordCount
' set the number of rows displayed on this page
If (rsLogin_numRows < 0) Then
  rsLogin_numRows = rsLogin_total
Elseif (rsLogin_numRows = 0) Then
  rsLogin_numRows = 1
End If
' set the first and last displayed record
rsLogin_first = 1
rsLogin_last  = rsLogin_first + rsLogin_numRows - 1
' if we have the correct record count, check the other stats
If (rsLogin_total <> -1) Then
  If (rsLogin_first > rsLogin_total) Then rsLogin_first = rsLogin_total
  If (rsLogin_last > rsLogin_total) Then rsLogin_last = rsLogin_total
  If (rsLogin_numRows > rsLogin_total) Then rsLogin_numRows = rsLogin_total
End If
%>
<%
' *** Move To Record and Go To Record: declare variables
Set MM_rs    = rsLogin
MM_rsCount   = rsLogin_total
MM_size      = rsLogin_numRows
MM_uniqueCol = "userID"
MM_paramName = "admin"
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Specific Record: handle detail parameter
If (MM_paramIsDefined And MM_rsCount <> 0) Then
  ' get the value of the parameter
  param = Request.QueryString(MM_paramName)
  ' find the record with the unique column value equal to the parameter
value
  MM_offset = 0
  Do While (Not MM_rs.EOF)
    If (Cstr(MM_rs.Fields.Item(MM_uniqueCol).Value) = param) Then
      Exit Do
    End If
    MM_offset = MM_offset + 1
    MM_rs.MoveNext
  Loop
  ' if not found, set the number of records and reset the cursor
  If (MM_rs.EOF) Then
    If (MM_rsCount < 0) Then MM_rsCount = MM_offset
    If (MM_size < 0 Or MM_size > MM_offset) Then MM_size = MM_offset
    MM_offset = 0
    ' reset the cursor to the beginning
    If (MM_rs.CursorType > 0) Then
      MM_rs.MoveFirst
    Else
      MM_rs.Close
      MM_rs.Open
    End If
  End If
End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display
range
If (MM_rsCount = -1) Then
  ' walk to the end of the display range for this page
  i = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or i < MM_offset + MM_size))
    MM_rs.MoveNext
    i = i + 1
  Wend
  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = i
    If (MM_size < 0 Or MM_size > MM_rsCount) Then MM_size = MM_rsCount
  End If
  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If
  ' reset the cursor to the beginning
  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If
  ' move the cursor to the selected record
  i = 0
  While (Not MM_rs.EOF And i < MM_offset)
    MM_rs.MoveNext
    i = i + 1
  Wend
End If
%>
<%
' *** Move To Record: update recordset stats
' set the first and last displayed record
rsLogin_first = MM_offset + 1
rsLogin_last  = MM_offset + MM_size
If (MM_rsCount <> -1) Then
  If (rsLogin_first > MM_rsCount) Then rsLogin_first = MM_rsCount
  If (rsLogin_last > MM_rsCount) Then rsLogin_last = MM_rsCount
End If
' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<html>
<head>
etc......
-- 
Posted via Mailgate.ORG Server - 
http://www.Mailgate.ORG

 Quindi vi chiedo un aiuto per terminare questo mio primo progetto con ASP.
per info su ASP prova postare su news group dedicato it.comp.www.asp

 'Robusti');
Ciao