Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2003, 08:26 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login with username and password

Is there a standard block of code to use as a login. The connection is already open to the DB and I have 2 text box called "UserName" and "password" with a login button. I just need to call a function to login and I want "user" to hold the session variable so I can use in a select case

Thanks

__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old November 19th, 2003, 10:51 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

There is no standard block of code for a login feature. You need to figure out what has to happen to log in the user. If this is checking the username and password against a database table, then that's what you need to do. You could create this as a function so you could use it in multiple places if need be (if that's what you mean by "standard block").

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 11:03 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay then my question is can I use this in my form tag to call my function in a ConformLogin.asp
<FORM ACTION="ConfirmLogin.asp" NAME="login" METHOD="POST">
If so, do I need asp code aroud the two text boxes. How does the function know what the text boxes are holding for values. Or can you just use the name given to the text boxes(declared in the form tags)in the function or do they have to be assign to variables??

Thanks for your help

 
Old November 19th, 2003, 11:19 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I guess I'm not quite sure of your goal here. Do you have a login form on several pages? If that's what you are trying to do, then you could have the login form point to the same page and you only need to have that one page handle. You just have to make sure that you draw the form the same (with the same names for the input boxes).

If you want to have a login form in multiple places, I'd recommend creating a function that drawns said form so you don't have to code it over and over. Put this function in an include file. Any page that's wants to have the login form on the page can then just call the drawLoginForm() function. The form always points to the same page (confirmlogin.asp)

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 11:54 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess I am confusing myself as well as you. In my confirmLogin.asp I have it set up to validate the user name and password with the database. And I only have one place to login, I just thought it would be cleaner if I used 1 file to login with. So I need to call the confirmLogin.asp from my form, I tried this but it's not working

<script Language="vbscript">
sub Login_OnCLick()
    session("UserID") = "UserId"
    session("Password") = "Password"

response.redirect "ConfirmLogin.asp"
end sub
</script>

Assuming my confirmLogin code is correct how do I get this part of it to work, going from the form to the confirmLogin.asp. I called each text box UserId and Password respectively. Thanks for your help






Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding Username and password kuku_ashu Javascript How-To 0 January 4th, 2008 11:28 AM
username and password abhi_loveu2002 ASP.NET 2.0 Basics 1 December 14th, 2006 05:25 AM
Username and password Hennie Access 1 July 28th, 2006 12:43 AM
username/password creation of login page in asp undercurrent Classic ASP Basics 3 March 21st, 2005 08:38 PM
MySQL Password and username Yee MySQL 2 November 1st, 2004 01:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.