|
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";}
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
|
|
|