Javascript help needed

LanceM

Senior member
Mar 13, 2004
999
0
0
We have a list of users in a spreadsheet. Each user will receive, in direct mail, a coupon code that is associated, in this spreadsheet only, with their online username.

We want a user to be able to log in to our site and enter their coupon code. A script would then check this spreadsheet (or whatever we need to convert it to) and -- if the username and coupon code match -- direct the site visitor to a new page.

Anything out there that can be tailored to our needs?

In short:
1. Look up user name, among ~40k users.
2. If entered code matches user name, direct to next page.
 

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
As I'm sure you know, Javascript is a client-side language, meaning you would have to store your database/spreadsheet on the client machine to do this. Have you considered the performance implications? It would be *way* faster to do an SQL query on the server than try to parse through 40,000 users with a browser script, not to mention the time it would take to download the list in the first place, especially on dialup!
 

kingtas

Senior member
Aug 26, 2006
421
0
0
Do you need to check the spreadsheet? You can redirect a user via a php script and a mysql database.
 

LanceM

Senior member
Mar 13, 2004
999
0
0
Yeah, that's sort of the problem... we have no access to SQL/MySQL or PHP for this client. My experience is in information architecture and design (yep, real boring crap), and I haven't touched javascript in nine years so I'm unfamiliar with the latest tricks and workarounds. Plus, half our employees are gone today for the holiday, so I had no one to ask.

Thanks, though, as this answer of "no can do" will help move things along!
 

GoatMonkey

Golden Member
Feb 25, 2005
1,253
0
0
If you could convert the spreadsheet column to an XML file you could probably come up with some JavaScript to go through that file and look for a name. It wouldn't be very secure though. If anyone did a viewsource they could see the name of your xml file and retrieve it to see the full list of usernames. Like the other guys said, a database would be the best idea.
 

Snapster

Diamond Member
Oct 14, 2001
3,917
0
0
It's not impossible to do in JavaScript, just highly highly unrecommended. Security and performance wise this would be a poor avenue to travel down. Server side script (PHP/.Net) and a database back end would be the best solution.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,284
3,905
75
Basically, you need something on the server side to validate that the user didn't just pull something out of the Javascript and bypass your security.

The best thing I can think of, without PHP or CSS or something, is that you could have one file for each user that is a simple redirect to your page. Then, the Javascript would direct the browser to the page of that name. For consistency and security, you could have the browser md5sum the name first.

The only question in this case would be, do you have enough web space for that many files?
 

sumguy1

Member
May 23, 2007
86
0
0
You mentioned you don't have access to PHP and MySQL or databases or anything like that. . .but what about PERL? Can you do a Perl/CGI script via that just uses a plain text file that resides on the server side as the database? Basically, you are not going to be able to do what you want "correctly" or securely at all without SOME kind of server side processing to handle it. Naturally, you would want to be sure not to put this text file someplace where it would not be accessible via an http request but where only the PERL script could read it or somebody manually updating it in a shell session or something.
 

trexpesto

Golden Member
Jun 3, 2004
1,237
0
0
If it is an excel spreadsheet, it can be configured as an JDBC-ODBC data source. This is where I first read it:

http://www.javaworld.com/javaw.../04-qa-0629-excel.html

It's a handy thing for entering static test data in early development phases.

Hope it helps. PS: Better check what happens when the file is opened for writing - does it lock others out. You'd hope not, at least that failures would be thrown back to the client.

Whoops Old Post sorry to bump ya.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
13
81
www.markbetz.net
Reading this closely it seems you already know you need a server-based solution.

We want a user to be able to log in to our site and enter their coupon code.

As has been mentioned elsewhere javascript is a browser-hosted client-side technology for the most part. You need some script on the server that logs the users in and redirects them.

The Excel spreadsheet is your authentication database. The server script needs to be able to pull data from it and compare it to the form variables submitted by the client. As trexpesto suggested, there are ODBC drivers for spreadsheets, or you could convert it to either XML as GoatMonkey suggested, or CSV. There are data source drivers for all these formats. A competent web developer could toss this redirector together for you in less than a day.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |