Form da CDONTS a CDOSYS

windt

Utente Attivo
7 Giu 2016
59
5
8
Ciao a tutti,
ho un form in CDONTS che vorrei trasformare in CDOSYS che riporto sotto. In CDONTS funzionava ma con le nuove configurazione dei server è cambiato tutto. A dire il vero non sono molto capace :-( qualcuno può aiutarmi ?
Grazie per l'attenzione.
ASP.net:
<!--#include file="../xxxxx/conn.asp"-->

<!--#include file="../xxxxx/connopencofigurazione.asp"-->

<%



':::::::::::::::::::::::::: Funzione per generare una password casuale :::::::::::::::::::::::::::::


Function Password_GenPass( nNoChars, sValidChars )


    Const szDefault = "ABCDEFGHIJKLMNOPQRSTUVXYZ0123456789"

  

    Randomize

  

   If sValidChars = "" Then

        sValidChars = szDefault       

    End If

    nLength = Len( sValidChars )

  

    For nCount = 1 To nNoChars

        nNumber = Int((nLength * Rnd) + 1)

        sRet = sRet & Mid( sValidChars, nNumber, 1 )

    Next

    Password_GenPass = sRet   

End Function


'::::::::::: Fine Funzione per la password casuale


ControllaAzione = request("Modulo")


Select case ControllaAzione

    case "Registrazione"


'::::::::::: Fisso il problema dell'apostrofo con Function FixQuotes

      

       Function FixQuotes(strTxt)

       FixQuotes = Replace(strTxt, "'", "''")

       End Function

      

       sOtherId = Password_GenPass( 10, "" )

       username = FixQuotes(request.form("username"))

        email = FixQuotes(request.form("email"))

        Nome = FixQuotes(request.form("Nome"))

        Cognome = FixQuotes(request.form("Cognome"))

        Citta = FixQuotes(request.form("citta"))

        provincia = FixQuotes(request.form("provincia"))

        cap = FixQuotes(request.form("cap"))

        telefono = FixQuotes(request.form("telefono"))

        Fax = FixQuotes(request.form("Fax"))

        Via = FixQuotes(request.form("Via"))

        Home = FixQuotes(request.form("home"))

        IP = Request.ServerVariables("REMOTE_ADDR")

      

'::::::::::: Leggo i dati nel Database per assicurarmi che la password

'::::::::::: ho l'username ed E-mail non siano già presenti nel database


     Set RS = Server.CreateObject("ADODB.Recordset")

     SQL = "SELECT passw FROM Utenti WHERE passw='"&sOtherId&"' or username='"& username &"'"

     RS.open sql,Conn

If not RS.BOF Then

     ErrorMessage = "<P><B><center><font size=""3"" face=""Arial""><font color=""Red"">Attenzione!! <br><br>Username già scelto</font></B></center></P>"

Else

     Set RS = Server.CreateObject("ADODB.Recordset")

     SQL = "SELECT username FROM Annunci WHERE username='"& username &"'"

     RS.open sql,Conn

    

If not RS.BOF Then

     ErrorMessage = "<P><B><center><font size=""3"" face=""Arial""><font color=""Red"">Attenzione!! <br><br>Username già scelto</font></B></center></P>"

Else

  

    Set RS = Server.CreateObject("ADODB.Recordset")

        SQL = "SELECT email FROM Utenti WHERE email='"& email &"'"

    RS.open sql,Conn


If not RS.BOF Then

  ErrorMessage = "<P><B><center><font size=""3"" face=""Arial""><font color=""Red"">Attenzione!!<br><br>email presente nel database</font></B></center></P>"

Else


'::::::::::: Se tutto è OK inserisco i nuovi dati nel database


    if rs.eof and rs.bof then

  

        Set RS = Server.CreateObject("ADODB.Recordset")

        SQLL= "SELECT username, passw, nome, email, cognome, citta, provincia, cap, telefono, fax, via, DataIscrizione, home, IP_Utente FROM utenti"

        RS.Open SQLL,conn,2,3

          

        RS.AddNew

      

            RS("username") = FixQuotes(request.form("username"))

            RS("passw")= sOtherId

            RS("email")= FixQuotes(request.form("email"))

            RS("Nome")= FixQuotes(request.form("Nome"))

            RS("cognome")= FixQuotes(request.form("Cognome"))

            RS("Citta")= FixQuotes(request.form("citta"))

            RS("provincia")= FixQuotes(request.form("provincia"))

            RS("cap")= FixQuotes(request.form("cap"))

            RS("telefono")= FixQuotes(request.form("telefono"))

            RS("Fax")= FixQuotes(request.form("Fax"))

            RS("Via")= FixQuotes(request.form("Via"))

            RS("home")= FixQuotes(request.form("home"))

            RS("IP_Utente")= IP

            RS("DataIscrizione")= Now()

          

        RS.Update


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

':                             Conferma email                               :

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


strMsgHeader = "Ciao " & FixQuotes(request.form("Nome")) & " " & FixQuotes(request.form("Cognome")) & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "La registrazione è stata efettuata. " & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "Questi sono i dati per effettuare il Login" & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "Username: "& FixQuotes(request.form("username")) & vbCrLf

strMsgHeader = strMsgHeader & "Password: "& sOtherId & vbCrLf & vbCrLf& vbCrLf

strMsgHeader = strMsgHeader & "Clicca per accedere al Login : " & ServerURL & "login.asp" & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "----------------------------------------------------" & vbcrlf

strMsgHeader = strMsgHeader & "Powered by "& Live_server & vbcrlf

strMsgHeader = strMsgHeader & Organizzazione

On error resume next

Set Mail = Server.CreateObject("CDONTS.NewMail")

Mail.MailFormat = html

Mail.from = R_emailRegitrazione

Mail.to = FixQuotes(request.form("email"))

Mail.Subject = R_OgEmailReg

Mail.Body = (strMsgHeader) & vbCrLf & vbCrLf & "** Original-IP:" & Request.ServerVariables("REMOTE_ADDR")

Mail.Importance = 2

Mail.Send


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

': Se è stata selezzionata la funzione di copia            :

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


If R_CopiaemailRegitrazione = True Then


strMsgHeader = "Ciao " & FixQuotes(request.form("Nome")) & " " & FixQuotes(request.form("Cognome")) & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "La registrazione è stata efettuata. " & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "Questi sono i dati per effettuare il Login" & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "Username: "& FixQuotes(request.form("username")) & vbCrLf

strMsgHeader = strMsgHeader & "Password: "& sOtherId & vbCrLf & vbCrLf& vbCrLf

strMsgHeader = strMsgHeader & "Clicca per accedere alla pagina Login : " & ServerURL & "login.asp" & vbCrLf & vbCrLf

strMsgHeader = strMsgHeader & "----------------------------------------------------" & vbcrlf

strMsgHeader = strMsgHeader & "Powered by "& Live_server & vbcrlf

strMsgHeader = strMsgHeader & Organizzazione

On error resume next

Set Mail = Server.CreateObject("CDONTS.NewMail")

Mail.MailFormat = html

Mail.from = R_emailRegitrazione

Mail.to = R_emailRegitrazione

Mail.Subject = R_OgEmailReg

Mail.Body = (strMsgHeader) & vbCrLf & vbCrLf & "** Original-IP:" & Request.ServerVariables("REMOTE_ADDR")

Mail.Importance = 2

Mail.Send


End IF


RS.Close

Set Rs = nothing

Conn.close

Set Conn = nothing


Response.Redirect("registrazioneok.asp")


End if

End if

End if

End if


end select


%>   

<HTML>

<HEAD>


</HEAD>


<BODY>


</BODY>

</html>
 
Ultima modifica di un moderatore:

Paolo69

Moderatore
Membro dello Staff
MOD
18 Feb 2010
555
13
18
Italy
www.caprioli.info
Prova sostituendo questo codice:
Codice:
<%

Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.MailFormat = html
Mail.from = R_emailRegitrazione
Mail.to = R_emailRegitrazione
Mail.Subject = R_OgEmailReg
Mail.Body = (strMsgHeader) & vbCrLf & vbCrLf & "** Original-IP:" & Request.ServerVariables("REMOTE_ADDR")
Mail.Importance = 2
Mail.Send

%>

con questo codice:
Codice:
<%

    ' Windows XP / 2003 
    Set myMail            = CreateObject("CDO.Message")
        myMail.From        = R_emailRegitrazione ' MITTENTE
        myMail.To        = R_emailRegitrazione ' DESTINATARIO DIRETTO
        myMail.Subject     = R_OgEmailReg ' OGGETTO
'        myMail.Cc        = "[email protected]" ' PER CONOSCENZA
'        myMail.Bcc         = "[email protected]" ' DESTINATARIO NASCOSTO
        myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")        = 2
        myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")        = "smtp.aruba.it" 
        myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")    = "25"
        myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")     = ""
        myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")     = ""
        myMail.Configuration.Fields.Update
        myMail.HTMLBody    = (strMsgHeader) & vbCrLf & vbCrLf & "** Original-IP:" & Request.ServerVariables("REMOTE_ADDR")' Corpo messaggio    
        myMail.Send ' Invio
    Set myMail = Nothing

%>
Ricordati di personalizzare il server SMTP e relative porte.
 

Max 1

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
29 Feb 2012
4.449
338
83
@windt

Da regolamento del forum, come tutti noi sei tenuto ad usare il tag
PHP (2).png
quando posti del codice php, oppure la funzione codice dalla barra degli strumenti

box inserisci.png


Inoltre IMPORTANTE: Prima di creare una nuova discussione o di rispondere alle discussioni esistenti ricordati di leggere attentamente il Regolamento del Forum e l'eventuale regolamento specifico della sezione!
Grazie


Per questa volta te lo sistemo io ma mi raccomando per il futuro
 

windt

Utente Attivo
7 Giu 2016
59
5
8
Ciao Paolo, grazie per la risposta tempestiva. Ho provato a fare come mi hai detto e putroppo non funziona, non arriva la mail al destinatario :-(
 

Paolo69

Moderatore
Membro dello Staff
MOD
18 Feb 2010
555
13
18
Italy
www.caprioli.info
Buongiorno @windt ,
il codice di spedizione suggerito lo devi inserire in due sezioni diverse, infatti esaminado il tuo codice, puoi notare che verso la fine lo stesso si ripete due volte a seconda la condizione programmata.
Il server SMTP deve essere configurato secondo quanto disposto dal gestore del servizio web, cosa usi aruba?
Il sistema genera un errore?
Paolo
 

windt

Utente Attivo
7 Giu 2016
59
5
8
Buon giorno Paolo,
si il codice l'ho messo nelle due condizioni e il server SMTP l'ho configurato come da impostazioni di aruba.
Il sistema non genera nessun errore sia con il vecchio codice che con il nuovo, cioè in entrambi i casi mi permette di compilare il form e confermando con invio, sempre in entrambi i casi i dati vengono registrati sul DB, la schemata di inserimento dati da conferma che sarà inviata la mail per accettazione, e sempre in entrambi i casi non arriva nessuna mail di conferma della registrazione :-(
 
Discussioni simili
Autore Titolo Forum Risposte Data
G form con cdosys al posto di cdonts...come fare Classic ASP 1
S passare un valore da un form a un file .php con metodo post PHP 4
K Form che manda dati doppi PHP 1
K Problema form update PHP 2
Elisacau [Contact form 7] Inserire Numero auto incrementante WordPress 1
K form Inserimento record mysql PHP 2
I Form con selettore HTML e CSS 0
K [php]form invio dati PHP 0
G form invio multiplo con checkbox PHP 12
nivaria.achinet Intercettare form solo dopo invio Javascript 1
D Form contatti non funzionante HTML e CSS 0
A Stampare dati da form PHP 8
M Unire 2 funzioni per l'invio di un form e con l'apertura di un div Javascript 0
I Form HTML e CSS 17
otto9due $_FILE non passa i dati dal form PHP 1
M Form: come tornare ai campi già compilati dopo invio PHP 1
G Invio form con PHP PHP 3
felino Form action costum e parametri in queryString WordPress 1
M Come recuperare molteplici input form PHP 1
M Collegamento tra form html e script php PHP 4
L form immagini per il database PHP 0
A form PHP prenotazione tramite query PHP 2
A Form php prenotazione di un azienda sanitaria locale presso studio medico PHP 1
L inserimento form dati multipli ? PHP 0
L Problemi form Pagina php HTML e CSS 3
Cosina Creare bottone delete in form upload PHP 5
Cosina Creare bottone delete in form upload PHP 1
D Devo far funzionare un form di contatti PHP 4
B form gestione input PHP 2
V PHP form intersecate PHP 0
8 Javascript - PDF Form Javascript 0
J Form inserimento dati in database Ajax 1
E Gestione profilo utente tramite Form PHP 3
R [C#] Form principale si blocca mentre un altro Thread lavora .NET Framework 0
M Problema con controllo form in real time jQuery 6
D Form validazione Javascript 2
R form recovery pass PHP 0
V Symfony e i form PHP 3
M form con checkbox PHP 8
S come aggiustare un form di contatto? HTML e CSS 3
F query e form con select multipla PHP 17
MarcoGrazia Verifica di una stringa o di un nome proveniente da form Snippet PHP 0
A Inserimento dati nel database tramite form + altre operazioni PHP 18
websilvia Contact form using Bootstrap 3.3.4 PHP 8
Alex_70 Button non funziona nella form PHP 2
C Form email php su pagina index.html? PHP 21
W Rinominare Documenti Con Form Asp Classic ASP 9
S Invio email da form PHP 8
L form multipla php sql,errore in inserimento MySQL 0
L inviare i dati di un form ad un database PHP 6

Discussioni simili