CMS Traffic Systems Ltd. - Traffic Solutions
<%
if session("userid1")="" then
Response.Redirect "Login.asp?page=UploadContact"
end if
Function ReplaceName(Name)
Dim LeftStr , RightStr
Dim SingleFound ,AtPlace
AtPlace = InStr(1, Name, "'")
If AtPlace > 0 Then
SingleFound = True
LeftStr = Left(Name, InStr(AtPlace, Name, "'") - 1) & "''"
RightStr = Right(Name, Len(Name) - InStr(AtPlace, Name, "'"))
While SingleFound = True
If InStr(AtPlace + 1, Name, "'") > 0 Then
LeftStr = LeftStr & Mid(Name, AtPlace + 1, InStr(AtPlace + 1, Name, "'") - AtPlace - 1) & "''"
RightStr = Right(Name, Len(Name) - InStr(AtPlace + 1, Name, "'"))
AtPlace = InStr(AtPlace + 1, Name, "'")
SingleFound = True
Else
SingleFound = False
End If
Wend
ReplaceName = LeftStr & RightStr
Else
ReplaceName = Name
End If
End Function
%>
<%
set conn = Server.CreateObject("adodb.Connection")
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("tsl.mdb")
conn.open connstr
mode=Request.QueryString("mode")
if mode <>"" then
city=Request.Form("city")
add1=Request.Form("add1")
add2=Request.Form("add2")
add3=Request.Form("add3")
add_pin=Request.Form("add_pin")
add_tel=Request.Form("add_tel")
add_fax=Request.Form("add_fax")
add_email=Request.Form("add_email")
end if
if mode="Add" then
flag="Y"
strsql="insert into contact(city,add1,add2,add3,add_pin,add_tel,add_fax,add_email"
strsql=strsql&") values "
strsql=strsql&"('"&ReplaceName(city)&"','"&ReplaceName(add1)&"','"&ReplaceName(add2)&"','"&ReplaceName(add3)&"','"&add_pin&"','"&add_tel&"','"&add_fax&"','"&ReplaceName(add_email)&"')"
end if
if mode="Modify" then
flag="Y"
cat_id=Request.QueryString("cat_id")
strsql="update contact set city='"&ReplaceName(city)&"',add1='"&ReplaceName(add1)
strsql=strsql&"',add2='"&ReplaceName(add2)&"',add3='"&ReplaceName(add3)&"',add_pin='"&add_pin
strsql=strsql&"',add_tel='"&add_tel&"',add_fax='"&add_fax&"',add_email='"&ReplaceName(add_email)
strsql=strsql&"'"
strsql=strsql&" where cat_id="&cat_id
end if
if mode="Delete" then
flag="Y"
cat_id=Request.QueryString("cat_id")
strsql="Delete from contact where cat_id="&cat_id
end if
if flag="Y" then
'Response.Write(strsql)
conn.Execute strsql
end if
conn.Close
if ((IsEmpty(mode)) or isnull(trim(mode)) or mode="") then
mode="No"
end if
%>