Home arrow ASP arrow Page 3 - Central Scoreboard with Flash and ASP
ASP

Central Scoreboard with Flash and ASP


Adding a few flash games to your site is always a great way to get visitors to stay on your site a bit longer and even keep them coming back. It’s well known that one of the best ways to keep visitors coming back is interactivity. So why not let your visitors battle it out between each other?

Author Info:
By: Chris Worfolk
Rating: 4 stars4 stars4 stars4 stars4 stars / 117
March 22, 2004
TABLE OF CONTENTS:
  1. · Central Scoreboard with Flash and ASP
  2. · The database
  3. · Adding player’s scores
  4. · The Flash file

print this article
SEARCH DEVARTICLES

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.

 


blog comments powered by Disqus
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...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials