Asp Programming Lab - 250412 - 232338
Asp Programming Lab - 250412 - 232338
Last visit date: " & lastVisitDate &
") Response. Write("Last visit time: " & lastVisitTime & "
") Response. Write('Total number of visits: *& visitCount & "«/p>") If visitCount = 1 Then Response.Write('
Welcome to your first visit!
") End if > % " Create a connection to the database Dim conn, rs, sql, userName, userFlavor, iceCreamPrice "Initialize connection Set conn = Server.CreateObject(‘ADODB.Connection") conn.Open “Your_Connection_String” ' Replace with your actual database connection string * Check ifthe form is submitted If Request. ServerVariables(REQUEST_METHOD") "Get the values from the form userName = Request. Form(name") userFlavor = Request.Form(“flavor") POST" Then "Query to get the price of the selected flavor sql = "SELECT price FROM IceCreams WHERE flavor Set rs = conn.Execute(sql) &userFlavor &™* Check if the flavor is found in the database If Not rs.EOF Then iceCreamPrice = rs(‘price") Response. Write("Hello, " & userName & "I The price of *& userFlavor & ice cream is $" & iceCreamPrice & "
") Else Response. Write("Sorry, we donit have ” & userFlavor &" ice cream available.
") End if "Close the recordset rs.Close Set rs = Nothing Else "Ifthe form hasn't been submitted, display the form Response.Write("Login successful. You have 100 seconds to interact with this page.
") Else Response. Write("Incorrect password. Please try again.
") End if Else Response. Write("Usemame not found. Please register or try again.
") EndIf "Clean up rs.Close Set rs = Nothing conn.Close Set conn = Nothing Else * Check if the user is logged in and if the session has expired If Not IsEmpty(Session(‘username")) Then " Check the login time loginTimestamp = Ses \("login_time") " Calculate the difference in seconds between now and the login time If DateDiff('s’, loginTimestamp, Now()) > 100 Then * Expired session, redirect to login page Response.Redirect(‘login.asp) End if End if “Display the login form ifthe user is not logged in or ifthe session expired If IsEmpty(Session('username')) Then Response. Write("Name: " & name & "
") ‘Address: " & address & "
") 'Selected Courses:
" & selectedCoursesList &
Total Fees: $" & totalFees & "
") Else "Display the form if not submitted oodLast visit date: " & lastVisitDate &
") Response. Write(Last visit time: "& lastVisitTime & "Total number of visits: *& visitCount & "«/p>") If visitCount = 1 Then Response.Write('
Welcome to your first visit!
") End if >