'PAGINA PER L'INVIO DEI DATI
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>INSERIMENTO DI DATI IN UN DATABASE</title> </head> <body style="font-family: verdana; font-size: 10pt"> <h2 align="center">INSERIMENTO DI DATI IN UN DATABASE</h2> <p>Questo esempio consente di inserire i dati un database.</p> <form method="POST" action="Inserimento1b.asp"> <p>Nome: <input type="text" name="nome" size="20"></p> <p>Cognome: <input type="text" name="cognome" size="20"></p> <p>Email: <input type="text" name="email" size="20"></p> <p><input type="submit" value="Salva i dati nel database"></p> </form> </body> </html> 'PAGINA PER IL SALVATAGGIO DEI DATI <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>INSERIMENTO DI DATI IN UN DATABASE</title> </head> <body style="font-family: verdana; font-size: 10pt"> <h2 align="center">INSERIMENTO DI DATI IN UN DATABASE</h2> <p>Questo esempio consente di inserire i dati un database.</p> <% on error resume next nome = Request.form("nome") cognome = Request.form("cognome") email = Request.form("email") dim conn dim rs set conn = Server.CreateObject("ADODB.Connection") set rs = Server.CreateObject("ADODB.Recordset") conn.Open "tutorial", "", "" SQL = "INSERT INTO insertData (nome, cognome, email) " SQL = SQL & "VALUES ('" & nome & "','" & cognome & "','" & email & "')" rs.Open SQL, conn If err.number>0 then response.write "<p>€ - Attenzione, hai commesso un errore nello script, controlla e riprova.</P>" elseif conn.errors.count> 0 then response.write "<p>Attenzione!</P>" response.write "<p>I dati inseriti non sono corretti, controllare se i campi obbligatori sono stati compilati.</P>" Else response.write "<p>Ok, i dati sono stati inseriti correttamente!!!!</p>" End if conn.Close %> <hr> <p> <% Response.Write("<a href="""&Request.ServerVariables("HTTP_REFERER")&""">Torna alla pagina precedente</a>") %> </p> </body> </html> |