chpt 8 - coding_1

Upload: sahil-shah

Post on 07-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 Chpt 8 - Coding_1

    1/7

    CHAPTER 8 - CODING

    The website code has been linked with the database using ASP VBScript. The database consists of the users Login ID, Password, other registration details and the

    users current Balance.

    Linking Code for Registration form:

  • 8/4/2019 Chpt 8 - Coding_1

    2/7

    MM_rsKey_cmd.Parameters.Append

    MM_rsKey_cmd.CreateParameter("param1", 200, 1, 255,MM_dupKeyUsernameValue) ' adVarChar

    Set MM_rsKey = MM_rsKey_cmd.Execute

    If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then

    ' the username was found - can not add the requested username

    MM_qsChar = "?"If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&"

    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar &

    "requsername=" & MM_dupKeyUsernameValueResponse.Redirect(MM_dupKeyRedirect)

    End If

    MM_rsKey.Close

    End If

    %>

  • 8/4/2019 Chpt 8 - Coding_1

    3/7

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2",

    202, 1, 255, Request.Form("Username")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3",

    202, 1, 255, Request.Form("Password")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 5,

    1, -1, MM_IIF(Request.Form("Age"), Request.Form("Age"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5",

    202, 1, 255, Request.Form("Gender")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6",

    202, 1, 255, Request.Form("City")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7",

    202, 1, 255, Request.Form("Email")) ' adVarWChar

    MM_editCmd.ExecuteMM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URLDim MM_editRedirectUrl

    MM_editRedirectUrl = "success.html"

    If (Request.QueryString "") ThenIf (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then

    MM_editRedirectUrl = MM_editRedirectUrl & "?" &

    Request.QueryString

    ElseMM_editRedirectUrl = MM_editRedirectUrl & "&" &

    Request.QueryString

    End IfEnd If

    Response.Redirect(MM_editRedirectUrl)

    End If

    End If%>

  • 8/4/2019 Chpt 8 - Coding_1

    4/7

    Linking code for Login page:

  • 8/4/2019 Chpt 8 - Coding_1

    5/7

    Session("MM_Username") = MM_valUsername

    If (MM_fldUserAuthorization "") Then

    Session("MM_UserAuthorization")

    =CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)

    ElseSession("MM_UserAuthorization") = ""

    End If

    If CStr(Request.QueryString("accessdenied")) "" And false Then

    MM_redirectLoginSuccess = Request.QueryString("accessdenied")

    End If

    MM_rsUser.Close

    Response.Redirect(MM_redirectLoginSuccess)

    End If

    MM_rsUser.CloseResponse.Redirect(MM_redirectLoginFailed)

    End If%>

    Figure 1AUTO LOAN CALCULATOR

  • 8/4/2019 Chpt 8 - Coding_1

    6/7

    Figure 2 - Homepage

    Figure 3 Compound Interest Calculator

  • 8/4/2019 Chpt 8 - Coding_1

    7/7

    Figure 4 Registration Form

    Figure 5 Simple Calculator