D
ddobrzenski
I am getting error messages with my ASP below. I don't have much experience
in this coding, so hopefully someone will be able to fix my code and get me
on my way.
Thanks,
Danny
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<%
' Declaring variables
Dim name, email, phone, username, password, location, contact,
data_source, con, sql_insert
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
names = ChkString(Request.Form("name"))
email = ChkString(Request.Form("email"))
phone = ChkString(Request.Form("phone"))
username = ChkString(Request.Form("username"))
passwords = ChkString(Request.Form("password"))
location = ChkString(Request.Form("location"))
contact = ChkString(Request.Form("contact"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("\db/mainnew.mdb")
sql_insert = "insert into customers (name, email, phone, username,
password, location, contact) values ('" & _
name & "', '" & email & "', '" & phone& "', '" & username& "',
'" & password& "', '" & location& "', '" & contact & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "Congratulations, all information was loaded into database."
%>
</body>
</html>
in this coding, so hopefully someone will be able to fix my code and get me
on my way.
Thanks,
Danny
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<%
' Declaring variables
Dim name, email, phone, username, password, location, contact,
data_source, con, sql_insert
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
names = ChkString(Request.Form("name"))
email = ChkString(Request.Form("email"))
phone = ChkString(Request.Form("phone"))
username = ChkString(Request.Form("username"))
passwords = ChkString(Request.Form("password"))
location = ChkString(Request.Form("location"))
contact = ChkString(Request.Form("contact"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("\db/mainnew.mdb")
sql_insert = "insert into customers (name, email, phone, username,
password, location, contact) values ('" & _
name & "', '" & email & "', '" & phone& "', '" & username& "',
'" & password& "', '" & location& "', '" & contact & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "Congratulations, all information was loaded into database."
%>
</body>
</html>