<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%>
<% Option Explicit
' On Error Resume Next %>
Download
<%
If IsEmpty(Request.QueryString("FileName")) Then ' Check the FileName is not empty.
Else 'If not then writ the (Start Automatically) meta of the page.
' Start auto download in 5 seconds (CONTENT='5').
Response.Write("")
End If
%>
<%
If IsEmpty(Request.QueryString("FileName")) Then
' Do the action according to the Request.Form("Actions") which we send it by a Button's Click.
Select Case Request.Form("Actions") ' Select the Action Case.
Case "Download" 'We want to downlaod (Clicking the Download button).
Dim ADOConnection, ADORecordset ' Variable for the ADO components.
Set ADOConnection = Server.CreateObject("ADODB.Connection") ' Create the (ADO Connection Component) to connect to database.
Set ADORecordset = Server.CreateObject("ADODB.Recordset") ' Create the (ADO Recordset Component).
ADOConnection.Provider = "Microsoft.Jet.OLEDB.4.0" ' Set the provider to the ADOConnection
' Now open the (Data Source), The Server.MapPath("\WorkStation\LoginInformation.mdb") indicate to the Server virtual path,
' and the data path ("\WorkStation\LoginInformation.mdb").
ADOConnection.Open ("Data Source=" & Server.MapPath("\WorkStation\LoginInformation.mdb")) ' Indicate to (C:\Inetpub\wwwroot\WorkStation\LoginInformation.mdb).
ADORecordset.ActiveConnection = ADOConnection ' Set the Active Connection.
' Prepare the (ADO Recordset Component) to work.
ADORecordset.CursorType = 3: ADORecordset.CursorLocation = 3: ADORecordset.LockType = 3
ADORecordset.Open("Select * From [UsersInfo] Where UserName ='" & Request.Form("UserName") & "' And Password='" & Request.Form("Password") & "'") ' Open the SQL string.
If ADORecordset.RecordCount > 0 Then ' Found the user.
Response.Redirect("?FileName=File.zip") ' Start download.
Else 'We didn't found the user, Rewrite the Form objects.
Call CreatTheForm("Uncorrect Uername or password, Try again.")
End If
ADORecordset.Close ' Close the Recordset.
Case Else ' Write the Form objects (No button was clicked).
Call CreatTheForm("Enter the Username and Password then click download ")
End Select
Else
' We checked the username and password and they are correct.
' so write the start downloading stuf :)
Response.Write("
")
Response.Write("
")
Response.Write("
")
Response.Write("
")
Response.Write("Your download will start in 5 seconds. ")
Response.Write("If it doesn't Start automatically click ")
Response.Write("here")
Response.Write("
")
Response.Write("
")
Response.Write("
")
End If
'__________________________________________________________________________________________________________________
Sub CreatTheForm (TheHeaderMsg) ' Sub to creat the form with header MSG.
Response.Write("")
End Sub
%>