<%option explicit%> <% '********************************************************* ' Display customer for gift Certificate ' Version 6.50 May 27, 2003 '********************************************************* Dim strPassword1, strPassword2 Dim msg, newcust Dim i, sAction, Oid, dbc, scartitem, arrCart, Length ' Main Logic dim Customeradmin SetupCustomer If request("new")<>"" then ResetCustomerSessionData SetSess "Login","" end if sAction=Request.form("Action") ' find out if we are being called via submit if sAction="" then sAction=Request.form("Action.x") end if Serror=GetSess("Loginerror") ' possible mesage from login SetSess "Loginerror","" ' error from shop login If sAction = "" Then ' no came from customer logic GetCustomerSessionData ' DisplayEverything ' Else sError="" ValidateData() ' need to validate anything, nothing is required if sError = "" Then UpdateCustomerInformation ' put in customer and order data ResponseRedirect GetSess("FollowonURL") else DisplayEverything end if end if ' End of main logic Sub DisplayEveryThing ShopPageHeader ' Normal page header if getconfig("xbreadcrumbs") = "Yes" then response.write "
" & getlang("langcommonhome") & " " &_ SubCatSeparator & "" & getlang("langCustAdmin01") & "" &_ SubCatSeparator & "" & getlang("langgiftbuy") & "" &_ SubCatSeparator & getlang("langformatcustomerinformation") & "
" & vbCrLf end if Response.Write "

" & getlang("langformatcustomerinformation") & "

" & vbCrLf Displayerrors ' any input errors GetCustomerSessionData ' get customer info from session If (GetSess("Login")="") and (Getsess("Lastname") = "") and (getconfig("xPromptForLogin") = "Yes") then AddLogin ' User login form else DisplayForm ' display customer and shipping form end if ' DisplayForm ' display customer and shipping form ShopPageTrailer ' Normal page trailer end Sub ' Sub DisplayForm() AddInformationTable Response.Write("
") If GetSess("Login")<>"" and GetSess("Lastname")<>"" then addSubmitButton end if ShopCustomerForm ' comments shopwriteheaderpic getlang("langCreate06"),"images/icons/note.gif" response.write "
" Response.Write "
" AddSubmitButton 'AddNewUser Response.Write("
") End Sub Sub ValidateData 'VP-ASP 6.50 - precautionary security fix strFirstname = cleanchars(Request.Form("strFirstname")) strLastname = cleanchars(Request.Form("strLastname")) strAddress = cleanchars(Request.Form("strAddress")) strCity = cleanchars(Request.Form("strCity")) strState = cleanchars(Request.Form("strState")) strPostCode = cleanchars(Request.Form("strPostCode")) strCountry = cleanchars(Request.Form("strCountry")) strCompany = cleanchars(Request.Form("strCompany")) strWebsite = cleanchars(Request.Form("strWebsite")) strPhone = cleanchars(Request.Form("strPhone")) strWorkphone = cleanchars(Request.Form("strWorkphone")) strMobilephone = cleanchars(Request.Form("strMobilephone")) strFax = cleanchars(Request.Form("strFax")) strEmail = cleanchars(Request.Form("strEmail")) strshipname = cleanchars(Request.Form("shipname")) strshipcompany = cleanchars(Request.Form("shipcompany")) strshipaddress = cleanchars(Request.Form("shipaddress")) strshiptown = cleanchars(Request.Form("shiptown")) strshipzip = cleanchars(Request.Form("shipzip")) strshipstate = cleanchars(Request.Form("shipstate")) strshipcountry = cleanchars(Request.Form("shipcountry")) strShipComment=cleanchars(request.form("shipcomment")) strPassword1 = cleanchars(Request.Form("strPassword1")) strPassword2 = cleanchars(Request.Form("strPassword2")) If strFirstname = "" Then sError = sError & getlang("LangCustFirstname") & getlang("Langcustrequired") & "
" End If If strLastname = "" Then sError = sError & getlang("LangCustLastname") & getlang("Langcustrequired") & "
" End If If strAddress = "" Then sError = sError & getlang("LangCustAddress") & getlang("Langcustrequired") & "
" End If If strCity = "" Then sError = sError & getlang("LangCustCity") & getlang("Langcustrequired") & "
" End If If getconfig("xIncludeStates")="Yes" and strState="??" then strstate="" end if If getconfig("xPromptForState")="Yes" then If strState = "" Then sError = sError & getlang("LangCustState") & getlang("Langcustrequired") & "
" End If end if If strPostCode = "" Then sError = sError & getlang("LangCustPostCode") & getlang("Langcustrequired") & "
" End If If strPhone = "" Then sError = sError & getlang("LangCustPhone") & getlang("Langcustrequired") & "
" End If If strEmail = "" Then sError = sError & getlang("LangCustEmail") & getlang("Langcustrequired") & "
" Else ValidateEmail end If If getconfig("xCountryRequired")="Yes" then If strCountry="" or strCountry="??" then sError = sError & getlang("LangCustCountry") & getlang("Langcustrequired") & "
" End If end if ValidatePassword End Sub Sub ValidatePassword Dim rc if ucase(getconfig("xpassword"))="YES" then if strPassword1<>"" then If StrPassword1<>strPassword2 then SError= SError & getlang("LangPasswordMismatch") & "
" else if len(strPassword1) >= 6 then CheckForDuplicate rc if rc > 0 then SError= SError & getlang("LangPasswordDuplicate") & "
" end if else Serror=Serror & getlang("LangPasswordLength") & "
" end if end if end if end if End sub Sub addLogin If GetSess("Login")<>"" and Getsess("Lastname") <>"" then exit sub end if If getconfig("xPromptForLogin")<>"Yes" then exit sub 'shopwriteheader getlang("LangCust01") shoploginform end sub Sub DisplayErrors if sError<> "" then shopwriteerror SError Serror="" end if end Sub Sub AddSubmitButton Response.Write "
" If Getconfig("xbuttoncontinue")="" then Response.Write("") else Response.Write("") end if Response.Write "
" end sub ' Sub CheckForDuplicate (rc) Dim testsql, rs, sql dim myconn, templastname templastname=replace(strlastname,"'","''") templastname=replace(templastname,"=","") OpenCustomerDb myconn sql = "select * from customers where lastname='" & templastname & "' and password ='" & strpassword1 & "'" sql = sql & " and email='" & stremail & "'" 'debugwrite sql Set rs = myconn.Execute(SQL) If Not rs.EOF Then rc=4 else rc=0 end if rs.close set rs=nothing shopclosedatabase myconn end sub Sub addnewUser response.write ("

" & getlang("LangLogin02") & "

") end sub Sub addInformationTable dim amount, total, count amount=Getsess("giftamount") count=Getsess("Giftcount") total=amount*count amount=shopformatcurrency(amount, Getconfig("xdecimalpoint")) total=shopformatcurrency(total, Getconfig("xdecimalpoint")) response.write "

" shopwriteheader count & " " & getlang("LangGiftCertificate") & " " & amount & " " & getlang("LangReportTotal") & " " & total &"
" If GetSess("Login")="" then ' Response.Write getlang("LangCustomerPrompt") & "
" end if Response.write "

" end Sub ' Sub ValidateEmail If Not InStr(strEmail, "@") > 1 Then Serror=Serror & getlang("LangInvalidEmail") & "
" end if End sub Sub SetupCustomer ' ********************************************************************** ' Set defaults here '********************************************************************** SetSess "CurrentURL", "shopgift2.asp" SetSess "FollowonURL","shopgift2.asp" ' force login to come back to us SetSess "smprice","" ' no price SetSess "ShipMethod","" ' no type end sub ' adds to customer table, order table, oitems table Sub UpdateCustomerInformation if getconfig("xAllowCustomerUpdates")="Yes" or GetSess("Login")="" then UpdateContact end if strCustomerid=GetSess("Customerid") strDiscount=GetSess("CustDiscount") UpdateCustomerSessionData If Customeradmin="" then SetSess "FollowonURL","shopcreateorder.asp" ' this is followon unless changed end if End Sub %>