codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Multiple destination pages with only one login page  Cynth at 07:38 on Monday, May 30, 2005
 

Howdy,

I have four pages on my site and each page requires a login. I don't want to have four login pages - I was hoping to put the javascript code for the various logins into the one loginscript page.

At the moment I am using Request.QueryString("URL"), no idea if this is the best plan. If I login incorrectly more than once, I get an error saying: "A URL is required."

Any advice would be great, thanks. Code is currently:

var valtest = Request.QueryString("URL");
if (valtest == "Edit") {
MM_redirectLoginSuccess = "/VesselData/X_rayTracerTestView_mnu_X_rayTraceTestView.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailVesselData.html";}
else if (valtest == "Admin") {
MM_redirectLoginSuccess = "/Admin/default_mnu_AdminSection.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailAdmin.html";}
else if (valtest == "DVMAudits") {
MM_redirectLoginSuccess = "/DVM/Audits_mnu_LoginDVMAudits.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailDVMAudits.html";}


  Re: Multiple destination pages with only one login page  Troy Wolf at 19:08 on Wednesday, June 01, 2005
 

I take it you are writing your server-side ASP pages using jscript? Why? There is nothing wrong with doing this, and many people do. However, the vast majority of ASP coders use VBScript for the server-side code. As a newbie, I encourage you to do what most other people are doing. This way, you'll be able to find code examples that apply to you.

When it comes to password protecting ASP pages, the way I learned from others and the method I've always used since is to create an authentication include file--perhaps name this login.asp. This code will look at the current session vars to see if login is currently logged in. If not, then redirect to or draw a login form.

login.asp will test the username and password against your database (or whatever method you use to store credentials -- could be an actual Windows user account). If auth fails, redraw the login form with perhaps a message indicating login failed. If auth passes, redirect back to the page originally requested. YOu can "remember" the page the user originally requested by saving the appropriate Server var in a cookie or in the session.

Look at some code examples online, think about what I've said here, and then ask specific questions as needed. I'll try to help you through this.

Troy Wolf: site expert
SnippetEdit Website Editor


  Re: Multiple destination pages with only one login page  Cynth at 12:23 on Monday, June 06, 2005
 

Hey Troy,

Thank you so much for your help and time.

I have my code in a loginscript.asp file and have managed to get it working with the following code:

var valtest = Request.QueryString("URL");
var access = Request.QueryString("access");
if ( valtest == "Edit") {
var MM_redirectLoginSuccess="/VesselData/X_rayTracerTestEdit_mnu_X_rayTraceTestEdit.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailVesselData_ampURL_Edit.html";
}
if (valtest == "View") {
var MM_redirectLoginSuccess="/VesselData/X_rayTracerTestView_mnu_X_rayTraceTestView.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailVesselData_ampURL_View.html";
}

var valtest = Request.QueryString("URL");
if (valtest == "Admin") {
var MM_redirectLoginSuccess="/Admin/Default_mnu_AdminSection.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailAdmin_ampURL_Admin.html";
}
var valtest = Request.QueryString("URL");
if (valtest == "DVMAudits") {
var MM_redirectLoginSuccess="/DVM/Audits_mnu_DVMAudits.html";
var MM_redirectLoginFailed="/forum/loginfail_mnu_LoginfailDVMAudits_ampURL_DVMAudits.html";
}

But in the meantime I will do an you advise and look at some code examples online. Thanks again for the help.









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  need to convert sockets in perl on linux to work on windows
•  Re: refresh parent after closing pop up window
•  Re: running a command in remote machine by using perl
•  Re: Save up to 80% on SSL Certificates, RapidSSL Certificate @ $ 11.00/yr.
•  Re: Need some help with javascript code in Unity!
•  Re: Copy files from one directory to another in a local network
•  Re: number of hours and minutes spent
•  Re: Saving a Picture or Image contained within a Picturebox into Windows Registry
•  Join Apache Lucene EuroCon 2010


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010