XML/XSL Portal

Multiple Stylesheet Aware
HideXML Documenting CodeHide
     
  
 
 

GetCustomer.asp

None.
No Comments Found.
Clientside Functions
  • CheckString (s, endchar) (1)
Include Files
  • /advworks/Disclaim.inc (1)
  • /advworks/srcform.inc (1)
Session Variables Set
  • CustomerFirstName (1)
  • CustomerID (1)
Session Variables Used
  • ConnectionString (1)
  • CustomerFirstName (4)
  • CustomerID (2)
Redirections
  • RESPONSE-REDIRECT > /advworks/Equipment/Shipping.asp (1)
Images Used
Tlc 190
190
Source
<script LANGUAGE="VBScript" RUNAT="Server"> FUNCTION CheckString (s, endchar) pos = InStr(s, "'") While pos > 0 s = Mid(s, 1, pos) & "'" & Mid(s, pos + 1) pos = InStr(pos + 2, s, "'") Wend CheckString="'" & s & "'" & endchar END FUNCTION </script> <% msg="" Action = Left(UCase(Request("Action")),5) ' Do Some form validation If Action = "ENTER" Then If Request("CompanyName") = "" OR _ Request("ContactFirstName") = "" OR _ Request("ContactLastName") = "" OR _ Request("BillingAddress") = "" OR _ Request("City") = "" OR _ Request("StateOrProvince") = "" OR _ Request("PostalCode") = "" OR _ Request("Country") = "" OR _ Request("PhoneNumber") = "" OR _ Request("EmailAddress") = "" OR _ Request("LevelOfExperience") = "" Then msg="<B><I>All fields must have a valid non-empty response.</I></B>" End If ' The form is valid and no missing fields If msg = "" Then sql = "insert into Customers (" &_ "CompanyName, " &_ "ContactFirstName, " &_ "ContactLastName, " &_ "BillingAddress, " &_ "City, " &_ "StateOrProvince, " &_ "PostalCode, " &_ "Country, " &_ "PhoneNumber, " &_ "EmailAddress, " &_ "LevelOfExperience) " &_ "VALUES ( " sql = sql & CheckString(Request("CompanyName"),",") sql = sql & CheckString(Request("ContactFirstName"),",") sql = sql & CheckString(Request("ContactLastName"),",") sql = sql & CheckString(Request("BillingAddress"), ",") sql = sql & CheckString(Request("City"), ",") sql = sql & CheckString(Request("StateorProvince"), ",") sql = sql & CheckString(Request("PostalCode"), ",") sql = sql & CheckString(Request("Country"), ",") sql = sql & CheckString(Request("PhoneNumber"), ",") sql = sql & CheckString(Request("EmailAddress"), ",") sql = sql & CheckString(Request("LevelOfExperience"), ")") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Session("ConnectionString") Conn.Execute(sql) ' For SQL Server, it is much more efficient to use the identity built in ' variable @@identity. sql = "select @@identity" ' For MS Access and other databases, use the max value just inserted. sql = "select max(CustomerID) from Customers" set rs = Conn.Execute(sql) CustomerID = rs(0) rs.Close Conn.Close Session("CustomerID")= CustomerID Session("CustomerFirstName") = Request("ContactFirstName").Item Response.Cookies("CustomerFirstName") = Request("ContactFirstName") Response.Cookies("CustomerFirstName").Expires = Date+365 Response.Cookies("CustomerFirstName").Path = "/advworks" Response.Cookies("CustomerID") = CustomerID Response.Cookies("CustomerID").Expires = Date+365 Response.Cookies("CustomerID").Path = "/advworks" Response.Redirect "/advworks/Equipment/Shipping.asp" End If 'msg = "" End If 'Action = "ENTER" %> <html> <head> <title>Adventure Works Sign Up Page</title></head> <body BACKGROUND="images/back_sub.gif" LINK="#800000" VLINK="#008040"> <font FACE="Verdana, Arial, Helvetica" SIZE="2"> <table WIDTH="600" BORDER="0"> <tr> <td> <img SRC="images/spacer.gif" ALIGN="RIGHT" WIDTH="100" ALT></td> <td COLSPAN="5"> <img SRC="images/hd_sign_up.gif" WIDTH="133" HEIGHT="42" ALT="Sign Up"><br> <hr SIZE="4"> </td> </tr> <tr> <td ROWSPAN="4" ALIGN="RIGHT" VALIGN="TOP"> <img SRC="images/spacer.gif" WIDTH="120" HEIGHT="350" ALIGN="RIGHT" ALT> </td> <td VALIGN="TOP" ALIGN="LEFT"> <font SIZE="2" FACE="Verdana, Arial, Helvetica"> <% ContactFirstName = Request("ContactFirstName") ' Check to see if this is a customer that got deleted from the database. If so ' they need to fill in the information again if Session("CustomerID") = -1 then Response.Write "<I><B>" & Session("CustomerFirstName") & "</B>, we need to update your information in our database</I><P>" ContactFirstName = Session("CustomerFirstName") end if %> So that we can service you better, please, take some time now to fill out the following form.</font> <p> </tr> <tr> <td> <!-- BEGIN Application Form --> <form ACTION="/advworks/equipment/GetCustomer.asp" METHOD="POST"> <% = msg %> <!-- BEGIN column header row --> <table CELLPADDING="5" COLSPAN="2"> <tr> <td WIDTH="310" BGCOLOR="#800000"><font COLOR="#FFFFFF" STYLE="Verdana, Arial, Helvetica" SIZE="2">Personal Information</font></td> <td WIDTH="310" BGCOLOR="#800000"><font COLOR="#FFFFFF" STYLE="Verdana, Arial, Helvetica" SIZE="2">Miscellaneous Information</font></td> </tr> <td BGCOLOR="f7efde" VALIGN="TOP"> <font SIZE="2"> First Name: <input TYPE="Text" NAME="ContactFirstName" VALUE="<%=ContactFirstName%>" SIZE="31" MAXLENGTH="35"><p> Last Name: <input TYPE="Text" NAME="ContactLastName" VALUE="<%=Request("ContactLastName")%>" SIZE="31" MAXLENGTH="35"><p> Company: <input TYPE="Text" NAME="CompanyName" VALUE="<%=Request("CompanyName")%>" SIZE="31" MAXLENGTH="35"><p> Address: <input TYPE="Text" NAME="BillingAddress" VALUE="<%=Request("BillingAddress")%>" SIZE="36" MAXLENGTH="36"> <table> <tr> <td><font SIZE="2">City:</font></td><td><font SIZE="2">State:</font></td><td><font SIZE="2">Postal Code:</font></td> </tr> <tr> <td> <input TYPE="Text" NAME="City" VALUE="<%=Request("City")%>" Size="8"> </td> <td> <input TYPE="Text" NAME="StateOrProvince" VALUE="<%=Request("StateOrProvince")%>" Size="2"> </td> <td> <input TYPE="Text" NAME="PostalCode" VALUE="<%=Request("PostalCode")%>" Size="5"> </td> </tr> </table> Phone:<br> <input TYPE="Text" NAME="PhoneNumber" VALUE="<%=Request("PhoneNumber")%>" Size="21"><br> Country:<br> <input TYPE="Text" NAME="Country" VALUE="<%=Request("Country")%>" Size="21"><br> </font> </td> <td BGCOLOR="f7efde" VALIGN="TOP"> <font SIZE="2"> Level of Experience: <select NAME="LevelOfExperience" SIZE="1"> <option>N/A <option>Beginner <option>Intermediate <option>Advanced </select><p> Email Address: <br> <input TYPE="Text" NAME="EmailAddress" VALUE="<%=Request("EmailAddress")%>" Size="35"><p> </font> </td> </tr> <tr> <td><input TYPE="SUBMIT" NAME="Action" VALUE="Enter Customer Info"></td> </tr> </table> </form> </tr> <!-- END Application Form --> <% REM Column Span Value %> <% HTML_CS = 3 %> <% HTML_INDENT = FALSE %> <!--#include virtual="/advworks/srcform.inc"--> <!--#include virtual="/advworks/Disclaim.inc"--> </table> </body> </html>
 
 
  
     
Open

Delete

View XML
View XSL