home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / MS_DEV / VID / SERVER / ASF / DATA.Z / GetCustomer.asp < prev    next >
Text File  |  1996-10-28  |  6KB  |  178 lines

  1. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  2.  FUNCTION CheckString (s, endchar)
  3.     pos = InStr(s, "'")
  4.     While pos > 0
  5.         s = Mid(s, 1, pos) & "'" & Mid(s, pos + 1)
  6.         pos = InStr(pos + 2, s, "'")
  7.     Wend
  8.    CheckString="'" & s & "'" & endchar
  9.    END FUNCTION
  10. </SCRIPT>
  11.  
  12. <%
  13.   msg=""
  14.   Action = Left(UCase(Request("Action")),5)
  15.  
  16. REM Do Some form validation
  17.   If Action = "ENTER" Then
  18.     If    Request("CompanyName") = "" OR _
  19.     Request("ContactFirstName") = "" OR _
  20.     Request("ContactLastName") = "" OR _
  21.     Request("BillingAddress") = "" OR _
  22.     Request("City") = "" OR _
  23.     Request("StateOrProvince") = "" OR _
  24.     Request("PostalCode") = "" OR _
  25.     Request("Country") = "" OR _
  26.     Request("PhoneNumber") = "" OR _
  27.     Request("EmailAddress") = "" OR _
  28.     Request("LevelOfExperience") = "" Then
  29.       msg="<B><I>All fields must have a valid non-empty response.</I></B>"
  30.     End If
  31.  
  32. REM The form is valid and no missing fields
  33.     If msg = "" Then
  34.     sql = "insert into Customers (" &_
  35.             "CompanyName, " &_
  36.             "ContactFirstName, " &_
  37.             "ContactLastName, " &_
  38.             "BillingAddress, " &_
  39.             "City, " &_
  40.             "StateOrProvince, " &_
  41.             "PostalCode, " &_
  42.             "Country, " &_
  43.             "PhoneNumber, " &_
  44.             "EmailAddress, " &_
  45.             "LevelOfExperience) " &_
  46.             "VALUES ( "
  47.     sql = sql & CheckString(Request("CompanyName"),",")
  48.     sql = sql & CheckString(Request("ContactFirstName"),",")
  49.     sql = sql & CheckString(Request("ContactLastName"),",")
  50.     sql = sql & CheckString(Request("BillingAddress"), ",")
  51.     sql = sql & CheckString(Request("City"), ",")
  52.     sql = sql & CheckString(Request("StateorProvince"), ",")
  53.     sql = sql & CheckString(Request("PostalCode"), ",")
  54.     sql = sql & CheckString(Request("Country"), ",")
  55.     sql = sql & CheckString(Request("PhoneNumber"), ",")
  56.     sql = sql & CheckString(Request("EmailAddress"), ",")
  57.     sql = sql & CheckString(Request("LevelOfExperience"), ")")
  58.     
  59.     Conn.Execute(sql)
  60.     set rs = Conn.Execute("select max(CustomerID) from Customers")
  61.     CustomerID = rs(0)
  62.     rs.Close
  63.         
  64.       Session("CustomerID")= CustomerID
  65.       Session("CustomerFirstName") = Request("ContactFirstName").Item
  66.       Response.Cookies("CustomerFirstName")         = Request("ContactFirstName")
  67.       Response.Cookies("CustomerFirstName").Expires = Date+365
  68.       Response.Cookies("CustomerFirstName").Path    = "/AdvWorks"
  69.       Response.Cookies("CustomerID")                = CustomerID
  70.       Response.Cookies("CustomerID").Expires        = Date+365
  71.       Response.Cookies("CustomerID").Path           = "/AdvWorks"
  72.       Response.Redirect "/AdvWorks/Equipment/Shipping.asp"
  73.     End If  'msg = ""
  74.   End If  'Action = "ENTER"
  75. %>
  76.  
  77. <HTML>
  78.  
  79. <HEAD>
  80. <TITLE>Adventure Works Sign Up Page</TITLE>
  81. </HEAD>
  82.  
  83. <BODY BACKGROUND="/AdvWorks/multimedia/images/back_sub.gif" LINK="#800000" VLINK="#008040"> 
  84. <FONT FACE="MS SANS SERIF" SIZE=2>
  85.  
  86. <TABLE WIDTH=600 BORDER=0>
  87.  
  88. <TR>
  89. <TD> 
  90. <IMG SRC="/AdvWorks/multimedia/images/spacer.GIF" ALIGN=RIGHT WIDTH=100 ALT="Space">
  91. </TD>
  92. <TD COLSPAN=5>
  93. <IMG SRC="/AdvWorks/multimedia/images/hd_sign_up.gif" width="133" height="42" ALT="Sign Up"><BR>
  94. <HR SIZE=4>
  95. </TD>
  96. </TR>
  97.  
  98. <TR>
  99. <TD ROWSPAN=4 ALIGN=RIGHT VALIGN=TOP>
  100. <IMG SRC="/AdvWorks/multimedia/images/spacer.gif" WIDTH=120 HEIGHT=350 ALIGN=RIGHT ALT="Spacer">
  101. </TD>
  102. <TD VALIGN=TOP ALIGN=LEFT>
  103. <FONT SIZE=2 FACE="MS SANS SERIF">
  104. <%
  105. ContactFirstName = Request("ContactFirstName")
  106. ' Check to see if this is a customer that got deleted from the database.   If so
  107. ' they need to fill in the information again
  108. if Session("CustomerID") = -1 then
  109.   Response.Write "<I><B>" & Session("CustomerFirstName") & "</B>, we need to update your information in our database</I><P>"
  110.   ContactFirstName = Session("CustomerFirstName")
  111. end if
  112. %>
  113. So that we can service you better, please, take some time now to fill out the
  114. following form.</FONT>
  115. <P>
  116. </TR>
  117.  
  118. <TR>
  119. <TD>
  120. <!-- BEGIN Application Form -->
  121.  
  122. <FORM ACTION="/AdvWorks/equipment/GetCustomer.asp" METHOD=POST>
  123. <%=msg%>
  124. <!-- BEGIN column header row -->
  125. <TABLE CELLPADDING=5 COLSPAN=2>
  126. <TR>
  127. <TD WIDTH=310 BGCOLOR="#800000"><FONT COLOR="#FFFFFF" STYLE="ARIAL NARROW" SIZE=1>Personal Information</FONT></TD>
  128. <TD WIDTH=310 BGCOLOR="#800000"><FONT COLOR="#FFFFFF" STYLE="ARIAL NARROW" SIZE=1>Miscellaneous Information</FONT></TD>
  129. </TR>
  130. <TD BGCOLOR="f7efde" VALIGN=TOP>
  131. <FONT SIZE=2>
  132. First Name: <INPUT TYPE="Text" NAME="ContactFirstName" VALUE="<%=ContactFirstName%>" SIZE=31 MAXLENGTH=35><P>
  133. Last Name: <INPUT TYPE="Text" NAME="ContactLastName" VALUE="<%=Request("ContactLastName")%>" SIZE=31 MAXLENGTH=35><P>
  134. Company: <INPUT TYPE="Text" NAME="CompanyName" VALUE="<%=Request("CompanyName")%>" SIZE=31 MAXLENGTH=35><P>
  135. Address: <INPUT TYPE="Text" NAME="BillingAddress" VALUE="<%=Request("BillingAddress")%>" SIZE=36 MAXLENGTH=36><P>
  136. City:              State:   Postal Code:<BR>
  137. <INPUT TYPE="Text" NAME="City" VALUE="<%=Request("City")%>" Size=8>
  138. <INPUT TYPE="Text" NAME="StateOrProvince" VALUE="<%=Request("StateOrProvince")%>" Size=2>
  139. <INPUT TYPE="Text" NAME="PostalCode" VALUE="<%=Request("PostalCode")%>" Size=5><P>
  140. Country: <INPUT TYPE="Text" NAME="Country" VALUE="<%=Request("Country")%>" Size=21><BR>
  141. Phone: <INPUT TYPE="Text" NAME="PhoneNumber" VALUE="<%=Request("PhoneNumber")%>" Size=21><BR>
  142. </FONT>
  143. </TD>
  144.  
  145. <TD BGCOLOR="f7efde" VALIGN=TOP>
  146. <FONT SIZE=1>
  147. Level of Experience: 
  148. <SELECT NAME="LevelOfExperience" SIZE="1">
  149. <OPTION>N/A
  150. <OPTION>Beginner
  151. <OPTION>Intermediate
  152. <OPTION>Advanced
  153. </SELECT><P>
  154. Email Address: <BR> <INPUT TYPE="Text" NAME="EmailAddress" VALUE="<%=Request("EmailAddress")%>" Size=35><P> 
  155. </FONT>
  156. </TD>
  157. </TR>
  158. <TR>
  159. <TD><INPUT TYPE=SUBMIT NAME="Action" VALUE="Enter Customer Info"></TD>
  160. </TR>
  161. </TABLE>
  162. </FORM>
  163. </TR>
  164. <!-- END Application Form -->
  165.  
  166. <% REM Column Span Value %>
  167. <% HTML_CS = 3 %>
  168. <% HTML_INDENT = FALSE %>
  169. <!--#include virtual="/AdvWorks/Disclaim.inc"-->
  170.  
  171. </TABLE>
  172.  
  173. <!--#include virtual="/AdvWorks/srcform.inc"-->
  174.  
  175. </BODY>
  176.  
  177. </HTML>
  178.