Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Data insertion

Two pages: one is the form for the digitation of the data, the other the form for the insertion in the database.


First page

<html>
<head>
<title>insert data</title>
</head>
<body>
<p>Compile fields:</p>
<form method="POST" action="inserisci.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="Invia"></p>
</form>
</body>
</html>

Second page

<html>
<head>
<title>insert data </title>
</head>
<body>
<%
on error resume next
nome = Request.form("nome")
cognome = Request.form("cognome")
email = Request.form("email")
dim objconn
dim objrs
set objconn = Server.CreateObject("ADODB.Connection")
set objrs = Server.CreateObject("ADODB.Recordset")
objconn.Open "nomedatabase", "", ""
SQL = "INSERT INTO nometabella (nome, cognome, email) "
SQL = SQL & "VALUES ('" & nome & "','" & cognome & "','" & email & "')"
objrs.Open SQL, objconn
If err.number>0 then
  response.write "<p>Error inserting</P>"
elseif conn.errors.count> 0 then
  response.write "<p>Attention!</P>"
  response.write "<p>Incorrect data.</P>"
Else
  response.write "<p>Done!</p>"
End if
objconn.Close
%>
<hr>
<p>
<%
Response.Write("<a href="""&Request.ServerVariables("HTTP_REFERER")&""">Back</a>")
%>
</p>
</body>
</html>


Download code...


Print this page


 

Inizio pagina

risorse per webmaster