Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 July 28th, 2010, 03:27 PM
Registered User
 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post LOGIN PAGE

I AM NEW TO ASP,AND I HAVE BEEN PRACTICING IN CREATING SOME WEB PAGES,I WOULD LIKE TO NOW I CAN I CREATE A LOG IN PAGE,THAT VERIFIES THE CREDENTIALS OF THE USER,(NAME AND PASSWORD ARE USED AS CREDENTIALS)
IT USES A BOOLEAN FUCTION THAT CHECKS FOR THIS TWO PARAMETERS ON THE DATABASE,AND IF THEY EXIST IT RETURNS TRUE, IF DOES NOT,IT RETURNS FALSE.
IT ALSO HAS AN EVENT THAT CALLS THE BOOLEAN FUCTION,ON A ON-CLICK EVENT OF THE BUTTON.
I HAVE TRIED DOING,BT IT IS NOT WORKING,ANYONE WITH CODE,PLZ HELP,I NEED A VBSCRIPT CODE AND C#.
 
Old July 28th, 2010, 03:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

Please stop with the upper case..
what code did you write?? what part is problematic??

Can you post your code so we can try to fix it??? Also why are you using vbscript????

And please only post the relevant portion of it.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old July 29th, 2010, 06:53 AM
Registered User
 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post

Sorry for that,here is the code i used.



Partial class Login
Inherits system.web.UI.Page

Sub logcred()
session(''username'')=txtUsername.text
Session(''password'')=txtpassword.text

If validadeteCredential(cstr(session(''username'')),c str(session(''password'')))then
FormsAuthentication.RedirectFormLoginPage(txtUsern ame.text,true)
else
Me.lberror.text=''invalid credentials''
end if
end sub
function Validatecre
dentials(byval user as string,byval pass as tring)as boolean
dim strconn as string=''data source=.\sqlexpress;AttacDbfilename[DataDirectory]\botanica.mdf;Integrated security=true;User Instance=true''
Dim sqcon as new Data.sqlclient.sqlconnection(strconn)
Dim qry as new stringBuilder

qry.append(''select
count(*) from client where Emailaddress=''')
qry.append(user)
qry.append('''and password=''')
qry.append(pass)
qry.append('''')
Dim cmd as new data.sqlclient.sqlcommand(qry.Tostring,sqcon)
dim svalue as integer
sqcon.open()
svalue=CInt(cmd.ExecuteScalar)
if svalue>0 then
return true
else
return false
end if
cmd.dispose()
sqcon.close()
end funcion
protected sub btnlogin_click(byval sender as object,byval e as system.eventargs) handles btnlogin.click
call logcred()
response.redirect(''home.aspx'')
end sub
class

Last edited by ABDUL; July 29th, 2010 at 07:41 AM.. Reason: MISTAKES
 
Old July 29th, 2010, 08:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello again..

Would be nice to know what type of error you receive..

You need to trace the code to see where is falling, because at first glance the code looks ok, except for some minor error that not affect the logic.

The compiler should be warning you about unreachable code in the validatecredential function (a return immediate terminates a function and return to the caller), and also use of cstr and cint are totally deprecated (there are only for backward compatibility). You shouldn't be using the word Call. Use a try catch to find errors.
Are you sure your database connection is open?
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old July 31st, 2010, 11:22 AM
Registered User
 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default thank you

Thank you for the help,its working correctly
 
Old July 31st, 2010, 01:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Where was the problem???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Login Page kumar.deepak1984 JSP Basics 1 May 12th, 2008 06:41 AM
Login Page ninel General .NET 0 November 2nd, 2006 11:40 AM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 07:09 PM
LOGIN PAGE (does not link to the next page) jim.sullivan@telus.net Classic ASP Databases 7 April 5th, 2006 01:28 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM





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