- Home
- Categorie
- Coding e Sistemistica
- Coding
- [ASP]come creare un login e registrazione utenti
- 
							
							
							
							
							
Grazie 1000 !!!! 
 
- 
							
							
							
							
							
Ho provato il tuo script ma con dispicere devo dirti che non mi funziona 
 l'ho modificato in base alla sessione del mio codice così:<% 
 if Session("registrato")="sicuro" then
 Response.Redirect("index.asp")
 end if
 %>
 Questo è il mio file che fa il check<% 
 dim user
 dim pwd
 dim url
 user=replace(request.form("form_user"),"'","''")
 pwd=replace(request.form("form_password"),"'","''")
 url=request.form("form_url")
 Dim Conn
 Set Conn = Server.CreateObject("ADODB.Connection")
 conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("mdb-database/pass.mdb")
 Set rs = Server.CreateObject("ADODB.Recordset")
 qry = "Select * from pass Where ((user='"
 qry = qry & user & "') AND (pwd='"
 qry = qry & pwd & "'));"
 rs.ActiveConnection = conn
 rs.CursorLocation = 2
 rs.Open qry
 Response.Expires=0
 if rs.EOF then
 response.redirect("check_out.htm")
 else
 session("registrato")="sicuro"
 rs.close
 set rs = nothing
 conn.close
 set conn = nothing
 response.redirect(url)
 end if
 %>
 
- 
							
							
							
							
							allora ammettiamo che la pagina che non vuoi far vedere è la pagina dopolaregistrazione.asp 
 e quella del login è login.aspallora 
 questo è il codice della pagina dololaregistrazione.asp :
 <%
 .......
 ...........
 %>tu il pezzo di codice che ti ho dato devi metterlo nel codice dalla pagina dopolaregistrazione.asp prima del suo codice <% .....................%> 
 capito..?
 ovviamente modifica la pagina index.asp con quella del tuo login!
 prova ad andare in questa pagina mia http://www.la-maglia-rosanero.com/foto_stadio/archiviofoto/add.asp come vedi on sei validato e ti rimanda alla pagina di login nel mio caso index.asp!tu hai INTEGRATO il pezzodi codice nel tuo codice...invece devi separarli per come te l'h o dato! 
 tipo<% if Session("Autenticato")<>"OK" then Response.Redirect("index.asp") end if %> <html> <head> <title>aggiungi record</title> </head> <body bgcolor="#FF99CC"> <div align="center"> <center> <form method="post" action="add-process.asp"> <p> </p> <table width="660" border="0" cellspacing="0" cellpadding="1" height="230" align="center" bgcolor="#000000" id="table1"> <tr> <td height="66" width="967"> <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="201" id="table2">questo è parte del codice dall pagina che ti ho appena fatto vedere 
 
- 
							
							
							
							
							
Ma è proprio quello che ho fatto, il tuo codice e cioè 
 <%
 if Session("registrato")="sicuro" then
 Response.Redirect("reicreg.htm")
 end if
 %>
 L' ho inserito in cima alla pagina da nascondere e cioè
 "reg_ok.htm" che sarebbe la pagina che appare dopo l'avvenuta corretta registrazione
 naturalmente l'ho modificata perchè la mia pag "check.asp" in session era diversa (vedi sopra) :bho:
 
- 
							
							
							
							
							
Aspetta.....Aspetta.....!!!! 
 Ho provato a rinominare la pag da nascondere (reg_ok.htm)
 da htm ad asp e funziona, ma allora le pag da nascondere devono per forza essere in asp ?
 
- 
							
							
							
							
							eh siamo in sezione asp  
 si solo per l'asp funziona 
 
- 
							
							
							
							
							
Ho provato a lasciare vuoti i campi e cliccare sul tasto registrami e mi appare un schermata bianca con un errore cosa dovrei inserire per obbligare l'utente a riempire tutti i campi ? Grazie !!!!! 
 
- 
							
							
							
							
							
@gelova said: Ho provato a lasciare vuoti i campi e cliccare sul tasto registrami e mi appare un schermata bianca con un errore cosa dovrei inserire per obbligare l'utente a riempire tutti i campi ? Grazie !!!!! Ricerca validazione form su google. Ad ogni modo ti consiglio di validare il form sia via javascript che, successivamente, via asp. Via asp devi controllare che i valori immessi dall'utente siano validi, ad esempio qualcosa del genere: nome = Request("nome") dataNascita = Request("dataNascita") If nome = "" then errore = "Nome é vuoto<br>" If dataNascita = "" or not IsDate(dataNascita) then errore = errore & "Data di nascita non valida<br>" ... If errore <> "" then Response.Write(errore) Response.End Else ... End if 
 
- 
							
							
							
							
							
Mi da questo errore > Microsoft VBScript compilation error '800a03f6' 
 Expected 'End'Il codice è questo <% 
 theSchema="http://schemas.microsoft.com/cdo/configuration/"
 Set cdoConfig=server.CreateObject("CDO.Configuration")
 cdoConfig.Fields.Item(theSchema & "sendusing")=2
 cdoConfig.Fields.Item(theSchema & "smtpserver")="smtp.soluzionepc.it"
 cdoConfig.Fields.Updateset cdoMessage=Server.CreateObject("CDO.Message") 
 cdoMessage.Configuration=cdoConfigcdoMessage.From=Request.Form("email") 
 cdoMessage.To="[email protected]"
 cdoMessage.Subject=Request.Form("subject")
 cdomessage.HtmlBody="Nome:" & request.form("nome") & "<br/>Cognome:" & Request.form("cognome") & "<br/>Citta:" & request.form("citta") & "<br/>Email:" & request.Form("email") & "<br/>Commenti:" & request.Form("commenti")
 cdoMessage.SendSet cdoMessage=Nothing 
 Set cdoConfig=Nothingnome = Request("nome") 
 cognome = Request("cognome")
 citta = Request(citta)
 email = Request(email)
 commenti = Request(commenti)If nome = "" then errore = "Nome é vuoto<br>" 
 If cognome = "" then errore = "cognome é vuoto<br>"
 If citta = "" then errore = "citta é vuoto<br>"
 If email = "" then errore = "email é vuoto<br>"
 If cognome = "" then errore = "commenti é vuoto<br>"
 If errore <> "" then
 Response.Write(errore)
 Response.End x:x x:x
 
- 
							
							
							
							
							
 
- 
							
							
							
							
							
L'errore è cambiato > CDO.Message.1 error '8004020d' 
 At least one of the From or Sender fields is required, and neither was found.
 /inviomail.asp, line 15il file inviomail.asp è questo <% 
 theSchema="http://schemas.microsoft.com/cdo/configuration/"
 Set cdoConfig=server.CreateObject("CDO.Configuration")
 cdoConfig.Fields.Item(theSchema & "sendusing")=2
 cdoConfig.Fields.Item(theSchema & "smtpserver")="smtp.soluzionepc.it"
 cdoConfig.Fields.Updateset cdoMessage=Server.CreateObject("CDO.Message") 
 cdoMessage.Configuration=cdoConfigcdoMessage.From=Request.Form("email") 
 cdoMessage.To="[email protected]"
 cdoMessage.Subject=Request.Form("subject")
 cdomessage.HtmlBody="Nome:" & request.form("nome") & "<br/>Cognome:" & Request.form("cognome") & "<br/>Citta:" & request.form("citta") & "<br/>Email:" & request.Form("email") & "<br/>Commenti:" & request.Form("commenti")
 cdoMessage.Send <--------------line 15Set cdoMessage=Nothing 
 Set cdoConfig=Nothingnome = Request("nome") 
 cognome = Request("cognome")
 citta = Request(citta)
 email = Request(email)
 commenti = Request(commenti)If nome = "" then errore = "Nome é vuoto<br>" 
 If cognome = "" then errore = "cognome é vuoto<br>"
 If citta = "" then errore = "citta é vuoto<br>"
 If email = "" then errore = "email é vuoto<br>"
 If cognome = "" then errore = "commenti é vuoto<br>"
 If errore <> "" then
 Response.Write(errore)
 End if
  x:x x:x
 
- 
							
							
							
							
							
@gelova said: L'errore è cambiato 
 il file inviomail.asp è questo
  x:x x:xAt least one of the From or Sender fields is required, and neither was found Cerchiamo di capirli i messaggi di errore. 
 Almeno un mittente è necessario.
 Quindi cdoMessage.From=Request.Form("email") non contiene l'email
 
- 
							
							
							
							
							
Allora sono due le cose o il form è costruito male o sono io che non ho capito un tubo...... 
 credo che l'unica cosa necessaria sia l'email del destinatario non quella del mittente,come faccio a sapere l'email del mittente (il mittente è colui che riempie il form) .
 Considera che il form ha questi campi Nome,Cognome,Città,email,Commenti (come si evince dal codice) :bho:
 
- 
							
							
							
							
							
@gelova said: Allora sono due le cose o il form è costruito male o sono io che non ho capito un tubo...... 
 credo che l'unica cosa necessaria sia l'email del destinatario non quella del mittente,come faccio a sapere l'email del mittente (il mittente è colui che riempie il form) .
 Considera che il form ha questi campi Nome,Cognome,Città,email,Commenti (come si evince dal codice) :bho:L'email mittente è quella inserita dall'utente (Request("email")) quindi sta bene così ma andrà in errore se lasci quel campo vuoto. Deve essere un campo obbligatorio. 
 
- 
							
							
							
							
							
Madai scusami ma questo codice che mi hai dato tu non dovrebbe servire appunto a validare i campi ? If nome = "" then errore = "Nome é vuoto<br>" 
 If cognome = "" then errore = "cognome é vuoto<br>"
 If citta = "" then errore = "citta é vuoto<br>"
 If email = "" then errore = "email é vuoto<br>"
 If cognome = "" then errore = "commenti é vuoto<br>"
 If errore <> "" then
 Response.Write(errore)
 End if
 Ma allora perchè se lascio il campo email vuoto mi dà la classica pag.bianca ?:bho:
 
- 
							
							
							
							
							
Perchè è sbagliato qui (occhio agli apici): nome = Request("nome") cognome = Request("cognome") citta = Request("citta") email = Request("email") commenti = Request("commenti")inoltre modifica il codice che ti ho dato come segue: If nome = "" then errore = "Nome é vuoto<br>" If cognome = "" then errore = errore & "cognome é vuoto<br>" If citta = "" then errore = errore & "citta é vuoto<br>" If email = "" then errore = errore & "email é vuoto<br>" If cognome = "" then errore = errore & "commenti é vuoto<br>" If errore <> "" then Response.Write(errore) End if
 
- 
							
							
							
							
							
Grazie dei suggerimenti madai, ho fatto le modifiche come da te suggerite 
 però se non viene riempito il campo email, mi esce sempre il messaggioCDO.Message.1 error '8004020d' 
 At least one of the From or Sender fields is required, and neither was found.
 /inviomail.asp, line 15Se viene riempito il campo email e si lasciano vuoti gli altri funziona !:bho: 
 
- 
							
							
							
							
							
Il controllo per la validazione dei campi va **ovviamente **messo in cima alla pagina non alla fine. **Prima **avviene il controllo, **dopo **se il controllo è positivo si prosegue con l'invio dell'email altrimenti si blocca stampando a video l'errore. PS: aggiungi Response.End in caso di errore, così: If nome = "" then errore = "Nome é vuoto<br>" If cognome = "" then errore = errore & "cognome é vuoto<br>" If citta = "" then errore = errore & "citta é vuoto<br>" If email = "" then errore = errore & "email é vuoto<br>" If cognome = "" then errore = errore & "commenti é vuoto<br>" If errore <> "" then Response.Write(errore) **Response.End** End if
 
- 
							
							
							
							
							
Funziona yahoooooo !!!!! Madai sei un grande.....un'ultima cosa.....so che ti ho stressato abbastanza....l'ultimo sforzo,il prog. funziona perfettamente con IE 6 mentre ho provato con Firefox e nella pagina che contiene il form (contatti.html) in cima prima dei campi la scritta <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> perchè ????? 
 
- 
							
							
							
							
							
