2 replies
by peter
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("yourfile.mdb")
Conn.Open DSN
strSQL = "Insert into your_table ("
strSQL = strSQL & "field1, "
strSQL = strSQL & "field2, "
strSQL = strSQL & "field3, "
strSQL = strSQL & "field4, "
strSQL = strSQL & "field5, "
strSQL = strSQL & "field6, "
strSQL = strSQL & "field7, "
strSQL = strSQL & "field8) "
strSQL = strSQL & "values( "
strSQL = strSQL & "'" & Request.Form("name") & "',"
strSQL = strSQL & "'" & Request.Form("name") & "',"
strSQL = strSQL & "'" & Request.Form("name") & "',"
strSQL = strSQL & "'" & Request.Form("name") & "',"
strSQL = strSQL & "'" & Request.Form("name") & "',"
strSQL = strSQL & "'" & Time() & "',"
strSQL = strSQL & "'" & Date() & "',"
strSQL = strSQL & "'" & Now() & "')"
Conn.Execute(strSQL)
%>
Remember to change the fieldnames of your database and the formname as well!
Hope you could use it.
Bestregards,
Peter F. Poulsen
by talleywho
Please keep in mind from Peter's example that by doing what he says you are allowing a user to modify a SQL statement that will be sent to your database. This is bad news, you should NEVER allow user input to actively modify your SQL queries if youvalue your data. This is called a SQL Injection attack, and very easy to do. Use code to validate the user input, the include it in your SQL statement.
Start your research here:
http://www.google.com/search?hl=en&ie=UTF-&oe=UTF-8&q=sql+injection
I do just have to mention that this is not Peter's fault, but the fault of Microsoft for giving out example code for ASP with such lack of care in providing novices a solid idea of how to program secure sites.
take care
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending