%@LANGUAGE="VBSCRIPT"%>
<%
'perform event handling
dim loginError
loginError = false
if Request.QueryString("logout") <> "" then
Session.Contents("loggedIn") = ""
End if
if Request.Form("login") <> "" then
'login attempted.
Dim objRSCheckLogin, objCmdCheckLogin
Set objRSCheckLogin = Server.CreateObject("ADODB.Recordset")
Set objCmdCheckLogin = Server.CreateObject("ADODB.Command")
objCmdCheckLogin.ActiveConnection = MM_business_list_STRING
objCmdCheckLogin.CommandText = "SELECT business_id, user_name, password FROM heatons_list WHERE user_name = '" & Trim(Request.Form("username")) & "'"
objCmdCheckLogin.CommandType = adCmdText
objRSCheckLogin.open objCmdCheckLogin
'if the recordset is not empty, we have found the correct business
if objRSCheckLogin.EOF then
loginError = true
else
'check password is correct
if Trim(Request.Form("password")) = Trim(objRSCheckLogin("password").Value) then
Session.Contents("loggedIn") = Trim(objRSCheckLogin("business_id").Value)
else
loginError = true
end if
end if
'close database connection
objRSCheckLogin.Close
Set objRSCheckLogin = Nothing
set objCmdCheckLogin = Nothing
'check passwords match
if Trim(Request.Form("password1")) <> Trim(Request.Form("password2")) then
passwordError = true
formError = true
end if
end if
'dimension variables
dim formError, blankFieldError, emailError, passwordError, updateSuccess
formError = false
blankFieldError = false
emailError = false
passwordError = false
updateSuccess = false
if (Request.Form("updateDetails") <> "") and (Session.Contents("loggedIn") <> "") then
'attempt to update business details
'Ensure all mandatory fields have values.
'Checks are: ensuring email address looks valid
'Removing "http://" from website addresses
'Start with blank fields
if (Trim(Request.Form("busname")) = "") or (Trim(Request.Form("address1")) = "") or (Trim(Request.Form("address2")) = "") or (Trim(Request.Form("address3")) = "") or (Trim(Request.Form("address4")) = "") then
blankFieldError = true
formError = true
end if
if (Trim(Request.Form("postcode5")) = "") or (Trim(Request.Form("timesopen")) = "") or (Trim(Request.Form("daysopen")) = "") or (Trim(Request.Form("telephone")) = "") or (Trim(Request.Form("contact")) = "") then
blankFieldError = true
formError = true
end if
if (Trim(Request.Form("email")) = "") or (Trim(Request.Form("position")) = "") or (Trim(Request.Form("yearstrading")) = "") or (Trim(Request.Form("furtherinfo")) = "") then
blankFieldError = true
formError = true
end if
'check e.mail address is valid
dim emailAddress
emailAddress = Trim(Request.Form("email"))
'e.mailAddress must contain an @ symbol and at least one period after it
dim atLocation
atLocation = InStr(emailAddress, "@")
if atLocation <> 0 then
'get the string after the @ symbol
dim afterAt
afterAt = Right(emailAddress, (Len(emailAddress) - atLocation))
dim periodLocation
periodLocation = InStr(afterAt, ".")
if periodLocation = 0 then
formError = true
emailError = true
end if
else
formError = true
emailError = true
end if
if formError = false then
'The information is fine, so save to database
'ensure all URLs are saved without http://
dim strURL
strURL = Trim(Request.Form("url"))
if ((InStr(strURL, "http://") <> 0) OR (InStr(strURL, "HTTP://") <> 0)) then
strURL = Right(strURL, (Len(strURL) - 7))
end if
dim strSQL
strSQL = "UPDATE poynton_list SET "
strSQL = strSQL + "business_name = " & "'" & Trim(Request.Form("busname"))& "', "
strSQL = strSQL + "address1 = " & "'" & Trim(Request.Form("address1"))& "', "
strSQL = strSQL + "address2 = " & "'" & Trim(Request.Form("address2"))& "', "
strSQL = strSQL + "address3 = " & "'" & Trim(Request.Form("address3"))& "', "
strSQL = strSQL + "address4 = " & "'" & Trim(Request.Form("address4"))& "', "
strSQL = strSQL + "postcode = " & "'" & Trim(Request.Form("postcode5"))& "', "
strSQL = strSQL + "web_address = " & "'" & strURL & "', "
strSQL = strSQL + "trade_hour = " & "'" & Trim(Request.Form("timesopen"))& "', "
strSQL = strSQL + "trade_days = " & "'" & Trim(Request.Form("daysopen"))& "', "
strSQL = strSQL + "telephone = " & "'" & Trim(Request.Form("telephone"))& "', "
strSQL = strSQL + "fax = " & "'" & Trim(Request.Form("faxno"))& "', "
strSQL = strSQL + "corr_name = " & "'" & Trim(Request.Form("contact"))& "', "
strSQL = strSQL + "email_address = " & "'" & Trim(Request.Form("email"))& "', "
strSQL = strSQL + "corr_pos = " & "'" & Trim(Request.Form("position"))& "', "
strSQL = strSQL + "trade_years = " & "'" & Trim(Request.Form("yearstrading"))& "', "
strSQL = strSQL + "notes = " & "'" & Trim(Request.Form("furtherinfo"))& "' "
strSQL = strSQL + "WHERE business_id = " & Session.Contents("loggedIn")
'open database connection
Dim objCom
Set objCom = Server.CreateObject("ADODB.Command")
objCom.ActiveConnection = MM_business_list_STRING
objCom.CommandText = strSQL
objCom.CommandType = adCmdText
objCom.Execute
'Response.Write strSQL
'save data
'close database connection
Set objCom = Nothing
updateSuccess = true
end if
end if
if (Request.Form("updatePassword") <> "") and (Session.Contents("loggedIn") <> "") then
if Trim(Request.Form("password1")) = Trim(Request.Form("password2")) then
'update passwords
dim objRSCheckPassword, objComCheckPassword, objComChangePassword, sqlString
set objRSCheckPassword = Server.CreateObject("ADODB.Recordset")
set objComCheckPassword = Server.CreateObject("ADODB.Command")
sqlString = "SELECT password FROM poynton_list WHERE business_id = " & Session.Contents("loggedIn")
objComCheckPassword.ActiveConnection = MM_business_list_STRING
objComCheckPassword.CommandText = sqlString
objComCheckPassword.CommandType = adCmdText
objRSCheckPassword.Open objComCheckPassword
if Trim(Request.Form("password")) <> Trim(objRSCheckPassword("password")) then
objRSCheckPassword.Close
formError = true
passwordError = true
else
objRSCheckPassword.Close
set objComChangePassword = Server.CreateObject("ADODB.Command")
objComChangePassword.ActiveConnection = MM_business_list_STRING
sqlString = "UPDATE poynton_list SET password = '" & Trim(Request.Form("password1"))
sqlString = sqlString & "' WHERE business_id = " & Session.Contents("loggedIn")
objComChangePassword.CommandText = sqlString
objComChangePassword.CommandType = adCmdText
objComChangePassword.Execute
set objComChangePassword = nothing
updateSuccess = true
end if
'objRSCheckPassword.Close
set objRSCheckPassword = nothing
set objComCheckPassword = nothing
else
formError = true
passwordError = true
end if
end if
%>
HEATON MOOR - HEATON MERSEY - HEATON CHAPEL - HEATON NORRIS - UPDATE BUSINESS PROFILE
<%
if Session.Contents("loggedIn") = "" then
'render login screen
%>
<%
else
'render normal fuction screen
Dim objRSBusiness, objCmdBusiness
Set objRSBusiness = Server.CreateObject("ADODB.Recordset")
Set objCmdBusiness = Server.CreateObject("ADODB.Command")
objCmdBusiness.ActiveConnection = MM_business_list_STRING
objCmdBusiness.CommandText = "SELECT * FROM heatons_list WHERE business_id = " & Session.Contents("loggedIn")
objCmdBusiness.CommandType = adCmdText
objRSBusiness.open objCmdBusiness
'if the recordset is not empty, we have found the correct business
if objRSBusiness.EOF then
Response.Write "A session error has occured!"
else
'render editable business details in a form
%>