Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 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 February 3rd, 2006, 11:31 PM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default Same Page Open Problem.

I have a problem in making my online testing application. I want the
user to enter his Login_ID and Password(already stored in database) in the home_page. Then this data is sent to the database. If the entered data doesn't match with that stored in the database, he will be asked to enter the details again on the same page but a message will be displayed in a LABEL that LoginID/Password doesn't match. This will happen three times on wrong entry and then when he enters the wrong data fourth time, he will be redirected to new page"Forget_Password". How the loop will be executed and where to store information whether it is the third time user is entering data or fourth time? Friends, Please help me. Any help will be appreciated.

Gaurav
__________________
Gaurav
 
Old February 4th, 2006, 05:09 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You could store that in the database, together with the user account.

E.g. you have a table with UserName, Password and LoginFailureCounts.

When a user logs in with the right name, but with a wrong password, you increase LoginFailureCounts. On successful login, you reset it to 0 again.

The good thing of this is that it works from multiple locations / browsers. However, it's also possible for a different user to deliberately screw up someone else's account....

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 4th, 2006, 06:45 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

Thanks Imar. But this is not the solution to my problem. I want to do this thing in Program. I want that if a user enters wrong Password, LoginID or both, same page(Login_Page) will open and the counter will be increased by 1. Initially counter will be equal to 1. So,when user clicks on Sign_In button, a loop will be run like this.

'If data doesn't match then this loop will execute
If counter < 3 Then
Label1.text = "error message"
password.text = ""
Else
Response.Redirect("other_page")
End If
counter = counter + 1

Now, the problem is that I dont know where to store this variable and how can I assign it an initial value of 0. Also, Keep in mind that I want to increment the value stored in this variable each time the above loop executes.

Thanks in advance.
 
Old February 4th, 2006, 10:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Why is that not a solution to your problem? It does exactly what you want: keep track of the number of failed logon attempts.

If you don't want to store that data in the database, you can also store it in a session variable. However, with a non-persistent data storage like session state, it's easy for the user to circumvent your security mechanism; they simply close and reopen the browser and they have three more tries to go...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 5th, 2006, 10:34 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

Imar, I tried Session variable. But I dont have any idea where and how to initialize value of this session variable to 0("zero"). Once I know how to initialize it to zero, rest I can do in my coding.

'I tried this code also:
Private Sub Page_Load(............)
 Session("var") = 0
End Sub

Private Button_Click(........) Handles Button.Click
 'If data doesn't match then
 If Session("var") <3
 'other code here
 End If
 Session("var") = Session("var") + 1


But on debugging, this is giving error. So, I want some way to initialize this session variable to 0 and then checking and incrementing its value in my code.

Thanks for replying to me ....

Gaurav
 
Old February 5th, 2006, 10:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I'd say that Session("var") = 0 should work.

However, since you load it in Page_Load, it gets reset every time the time loads (including post backs).

You can check for a Null value before you access the session variable:

Private myCount As Integer
If Not Session("var") Is Nothing Then
  myCount = Convert.ToInt32(Session("var"))
Else
  myCount = 0
  Session("var") = myCount
End If

HtH,

Imar





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a particular page in chm file using c# Rajesh.Prajapat C# 1 October 29th, 2008 04:31 AM
Using javascript to open a page toddw607 ASP.NET 2.0 Basics 9 May 13th, 2008 12:20 PM
Calender control - How to open next page? paragdongre ASP.NET 2.0 Basics 3 November 5th, 2007 01:28 AM
i need to open powerpoint in the html page Fatma General .NET 0 April 5th, 2006 04:13 PM
Open Notepad from within an HTML page? larry Javascript How-To 2 April 26th, 2004 10:02 AM





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