Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2002
    Location
    Burke, VA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Download counter

    What lanquage/method do i use to make a download counter? Where can i find a free example or learn to do it myself?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    miva would be ok, just.

    well - just about any serverside language will do the trick, sort of depends upon which languages your host supports. No point us detailing how miva would handle the job if you can only use asp or php.

    First tell us which languages you can potentially use, please.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hello? Forgotten about your post possibly? Lol..
    Anyway peeps who come along and read this may be in need of an answer.

    I'm not fluent in PHP yet so I'll stick to the ASP version.
    [code]
    <%
    DlFile = Request.QueryString("f")

    Set conn = Server.CreateObject("Adodb.Connection")
    Set rs = Server.CreateObject("Adodb.Recordset")


    Function Download(TheFile)
    Response.Redirect(TheFile)
    End Function

    Function CountIt(TheFile)
    SqlGetCount = "SELECT DlCount FROM DownloadCounter WHERE FileName = '"&TheFile&"'"
    rs.Open SqlGetCount, conn
    NewCount = rs("DlCount") + 1
    rs.Close
    SqlUpdateCount = "UPDATE DownloadCounter SET DlCount = "&NewCount&" WHERE FileName = '"&TheFile&"'"
    rs.Open SqlUpdateCount, conn
    rs.close
    End Function

    CountIt DlFile
    Download DlFile
    %>
    [code]

    Just use a querystring for the file name...
    <a href="download.asp?f=yourfile.zip>Download Now!</a>

    If you ever want to display the count on the page at the same time as they are downloading..
    <%=NewCount%>

    Or on another page:
    Code:
    Set conn = Server.CreateObject("Adodb.Connection")
    Set rs = Server.CreateObject("Adodb.Recordset")
    Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("YourDb.mdb")&";"
    Function GetCount(TheFile)
    SqlGetCount = "SELECT DlCount FROM DownloadCounter WHERE FileName = '" & TheFile & "'"
    rs.Open SqlGetCount, conn
    response.write(rs("DlCount"))
    End Function
    Now just call it like this..
    This file has been downloaded:<%=Call GetCount "YourFile.zip"%>
    Omnis mico antequam dominus Spookster!

  • #4
    New Coder
    Join Date
    Nov 2002
    Location
    Burke, VA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, i tried to post yesterday but it said the website was under maintenance...

    Thanks for the code. I don't really know and ASP or PHP, or even HTML for that matter, but i am learning and i will study that snippet. I understand how to program, though, so hopefully it won't take that long to understand.

  • #5
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    ASP isn't really complex at all. If you know BASIC then you almost automatically know ASP(vbscript).
    Omnis mico antequam dominus Spookster!

  • #6
    New Coder
    Join Date
    Nov 2002
    Location
    Burke, VA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, i already know quite a bit of VB, all i need is a good book on ASP and/or PHP. Gotta raid the library...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •