ASP
  Home arrow ASP arrow Page 3 - Central Scoreboard with Flash and ASP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Central Scoreboard with Flash and ASP
By: Chris Worfolk
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 79
    2004-03-22

    Table of Contents:
  • Central Scoreboard with Flash and ASP
  • The database
  • Adding player’s scores
  • The Flash file

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Central Scoreboard with Flash and ASP - Adding player’s scores


    (Page 3 of 4 )

    Next we need a file that will add player’s scores when they are sent. We also need a system to stop users adding scores to the database without actually playing the game. Bring up a new file in your text editor and save it as addscore.asp. This file will be sent variables from the flash movie:

    • Player – this will be the player’s name
    • Score – the player’s score
    • Passcode – this is a variable that makes sure the user is not just accessing the page using their browse

    In this file we open up the connection as normal but change the SQL:


    If Request.Form("passcode") = "XHjf5" Then
     
    Dim playername
    playername 
    "XXX"
    If Request
    .Form("player") <> "" Then
     playername 
    Request.Form("player")
    End If
    playername 
    = (Left(playername3))
     
    Dim conn
    conn 
    "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" Server.MapPath("database.mdb")
     
    set rs=Server.CreateObject("ADODB.recordset")
    rs
    .Source "INSERT INTO scores (player, score) VALUES ('" Request.Form("player") + "', " Request.Form("score") + ")"
    rs
    .ActiveConnection conn
    rs
    .Open()
     
    rs.Close()
    Set rs 
    Nothing
     
    End 
    If
     
    Response.Write(“Score Recorded. <A href="””javascript:window.close()”">Close Window</A>)



    The “if” around the whole script checks to make sure the variable has sent; if you’re using this on the web make sure you change the variable to something else. It’s important that your scoreboard is protected for adding scores although there is no need to project the script that displays results.

    All the script essentially does is insert the values into the database. If no player name is given the script uses XXX. This is because players will need to enter their names and some players won’t bother. There is also a function in the script to stop players having any more than 3 letters giving it an old fashioned arcade feel.

    The one problem that could arise in this script is players who enter 1 or 2 character long names. Personally I don’t mind this although if you want to insist on all players having 3 letters you could filter out these players and use the default using a script such as:


    Playername = (Left(playername3))
    Playercheck1 
    = (Left(playername1))
    Playercheck2 
    = (Left(playername2))
     
    If 
    playername playername1 Then
     ‘ this player only entered one letter
     Playername 
    “XXX”
    ElseIf playername 
    playername2 Then
     ‘ this player only entered two letters
     Playername 
    “XXX”
    End If

     

    Ok, you can save and close that file now. We are now done for scripting.

     

    More ASP Articles
    More By Chris Worfolk


       · Thank you for the scoreboard, once I click my button in flash to go to asp, it gives...
     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT