The Church Media Community
Equipping You to Communicate Effectively
support CMN & share a
library of 19K+ images, videos, etc
Go Pro!
 
Go Back   The Church Media Community > Website Design > Website Coding Discussions
Forgot Password?
                          Register

Website Coding Discussions PHP, MySQL, Java, Javascript, ASP, etc.

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old Monday, August 10th, 2009, 04:53 PM
New Church Media Member

 
 Join Date: Aug 2009 
 Last Online: Sunday, October 4th, 2009 
Red face Download file from textbox on webpage

I'm working on a website for my church and we have some books both in print and in a digital format. I'd like to make a downloads page where if they have bought the book and know the keycode in the front they can type it into a textbox on the website and download the digital version. So far i've been able to do it succesfully in javascript using a prompt and variable system where whatever they type is the variable and it sends them to that page. ie.

var text
text = prompt(type in the keycode)

location.href= "theurlwhatever" / text /".zip

obviously this is not the actual code but you get the drift. THe point is, it works if you know an actual keycode. if you leave it blank or put an incorrect keycode then it sends a 404 Error. I can't modify the 404 page so i'm left wondering:

Question: Is there a way to do this with ASP or javascript where the code will send you to another page of my choosing telling you to try again or that the book doesn't exist?

even this: if (text == "" ) alert "this does not exist"
shows the alert box and then sends them to error 404.


Please someone help. i'm not that good at javascript or anything else besides HTML and you help would be much appreciated
Reply With Quote Start a New Topic From This Comment
  #2 (permalink)  
Old Monday, August 10th, 2009, 05:46 PM
greg4god's Avatar
Church Media Regular

 
 Join Date: Jun 2007 
 Last Online: Yesterday 
Here are my thoughts, in order of importance (IMO)

The books in electronic format, are they freely distributable, or do you have the rights to distribute them.

You mention "if they bought the book". It has me wondering, are they buying it from you, or do you mean buy a book from a bookstore, and there is a code for accompanying information you are providing.

If you do not have the legal rights to distribute the material, this is a stopping point right here until you figure that out.

Now if all is good on that standpoint, what you ask can very easily be accomplished. However you mentioned ASP, and I'm a PHP guy. But if it can be done in one, it can be in another

Depending on the type of material, I would step it up to a system requiring a login, to help deter one person from buying the book and giving the code out to 20 others (if that is a possibility).

Also IMO, if you have access to a server-side language (ASP/PHP), it is best to handle it with that.

Set up a form, asking for the number. Pass it to a script for handling it which does the following:

1. Does simple validation. (ie. was something actually submitted, strip out any characters that would not possibly be in the code)

2. Check the directory where you are storing files for the existance of the one entered.

3. If found, give the file to the user, if not give an error back on the page with the form (ie. ebooks.asp?error=1) then at the top of the form, look to see if the GET variable has an element "error", if so, display a message.

Additional things I would do if you are not going to have a login system. Each night have it run a job to rename the directory to something like "books" and say 6 random #'s and use that.

-Greg

PS. Check out http://www.hotscripts.com/category/a...nts/documents/ for some pre-made scripts to do similar to this.
Reply With Quote Start a New Topic From This Comment
  #3 (permalink)  
Old Sunday, October 4th, 2009, 05:08 PM
New Church Media Member

 
 Join Date: Aug 2009 
 Last Online: Sunday, October 4th, 2009 
thanks

Thank you for the response i think i found a guy that could help me with the code. Yes the books are actually from authors in our church who sell them in our bookstore and have given permission to be downloaded electronically for use in the wordsearch software.
Reply With Quote Start a New Topic From This Comment
Reply

  The Church Media Community > Website Design > Website Coding Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:



Add to Google


Register Now for FREE!
Our records show you have not yet registered to our community. To sign up for your FREE account INSTANTLY fill out the form below!

Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
Agree to forum rules 


All times are GMT -6. The time now is 01:10 PM.

   
 
© 1995-2008, ChurchMedia™, ChurchMedia LLC

SEO by vBSEO 3.1.0