473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

login question

I put a little login (username and password textfields) in a web page, and
once the user able to login, I want the username and password textfields
will disappear, and replace with text "[UserName] has Login!]" in the same
position.

My question is how to make the username and password textfields disappear
and replace with "[UserName] has Login!]" in the same position?
This is the code I have done so far, but it has another problem: Even I
first check if the length of username field is non-zero first, it still
displays "Login Failed" before the user login. I guess it's the session
problem but don't know how to fix it.

<html>
<head>
<title>Login Form</title>
</head>
<body>
<form action="login.asp" method="post">
<table border="0">
<tr>
<td>User ID</td>
<td><input type="text" name="username"></td>
</tr>

<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
</table>
<input type="submit" value="submit">
<input type="reset" value="reset">
</form>
<!-- #include file="dbConn.asp"-->
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<%
If Len(Request.Form("username")) <> 0 Then
Dim strusername, strpassword, sqlStmt, objRS
strusername = Request.Form("username")
strpassword = Request.Form("password")
sqlStmt = "select * from [Password] where UserName = '" & strusername &
"'" & _
" And Password = " & "'" & strpassword & "'" & ";"
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open sqlStmt, strConnect ', adOpenStatic, adLockReadOnly,
adCmdTable
If objRS.EOF Then
Response.Write "Login Failed"
Else
Response.Write "Login Success: " & _
"UserName = " & strusername & "," & _
"Password = " & strpassword
End If
End If
%>
</body>
</html>
please advise! thanks!
john

Jul 19 '05 #1
1 2132
Works fine here, only the text you want is not there.
You Have this :
Response.Write "Login Success: " & _
"UserName = " & strusername & "," & _
"Password = " & strpassword
Seems you want to have this :
Response.Write strUsername & " has login."
Furthermore, you check the request.Form twice.
Try this :
strUsername = Trim(Request("Username"))
If strUsername = "" Then
'user did not fill in anything
else
'User did fill in something
end if

If you only check if the user has an account, so if there is a record
containing the un and pw,
try another query.
Select Count(Username) From [Password] ..... etc.
Now you allways have a record.
If the user is in the db you will have objRS.Fields(0) = 1
else objRS.Fields(0) will be 0
Instead of adOpenStatic you can use adForwardOnly, is faster, and do not use
the adCmdTable after it.

Meindert, MCP
I put a little login (username and password textfields) in a web page, and
once the user able to login, I want the username and password textfields
will disappear, and replace with text "[UserName] has Login!]" in the same
position.

My question is how to make the username and password textfields disappear
and replace with "[UserName] has Login!]" in the same position?
This is the code I have done so far, but it has another problem: Even I
first check if the length of username field is non-zero first, it still
displays "Login Failed" before the user login. I guess it's the session
problem but don't know how to fix it.

<html>
<head>
<title>Login Form</title>
</head>
<body>
<form action="login.asp" method="post">
<table border="0">
<tr>
<td>User ID</td>
<td><input type="text" name="username"></td>
</tr>

<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
</table>
<input type="submit" value="submit">
<input type="reset" value="reset">
</form>
<!-- #include file="dbConn.asp"-->
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<%
If Len(Request.Form("username")) <> 0 Then
Dim strusername, strpassword, sqlStmt, objRS
strusername = Request.Form("username")
strpassword = Request.Form("password")
sqlStmt = "select * from [Password] where UserName = '" & strusername & "'" & _
" And Password = " & "'" & strpassword & "'" & ";"
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open sqlStmt, strConnect ', adOpenStatic, adLockReadOnly,
adCmdTable
If objRS.EOF Then
Response.Write "Login Failed"
Else
Response.Write "Login Success: " & _
"UserName = " & strusername & "," & _
"Password = " & strpassword
End If
End If
%>
</body>
</html>
please advise! thanks!
john


Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Beginner | last post by:
I know this is an old question, but searching all over the internet plus several MS security conferences, still haven't got a straight anwser. Basically, the login.aspx is on one dedicated server...
7
by: Samuel Shulman | last post by:
Is there a method that will indicate the person who logged successfully is Logged and therefore allowed to browse freely other then using the...
1
by: Moss | last post by:
Hi, Sorry if this really is a newbie question, but hey, I'm a newbie, porting from a coldfusion background. I have been using the built in login feature however notice that it does appear to...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
9
by: Ben | last post by:
Hello, I'll bet this has been asked a million times but I can't seem to find a thread that gives the clear example I need. This PC has MySQL and IIS configured and running. The MySQL database is...
0
by: Jean | last post by:
Hi, I have a question about logins and sql server express and an ASP.NET aplication. I put this question in sql server newsgroup, but without real answer sofar. I created a login 'Network...
12
by: hotflash | last post by:
Hi Mark et. All, I have a question to see if you can educate me here since this is something new to me as well. I created a login page for the user to login and the ASP will check and redirect...
1
by: Kandiman | last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?... heres the code.. i think its on the value=true...
0
by: daokfella | last post by:
I have a Login.aspx page that takes care of all my login procedures (validation, lockouts, password change requirements, password retrieval, etc.) It works like a charm. However, now I'd like a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.