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.a sp" 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.as p"-->
<!-- METADATA TYPE="typelib"
FILE="C:\Progra m Files\Common
Files\System\ad o\msado15.dll" -->
<%
If Len(Request.For m("username") ) <> 0 Then
Dim strusername, strpassword, sqlStmt, objRS
strusername = Request.Form("u sername")
strpassword = Request.Form("p assword")
sqlStmt = "select * from [Password] where UserName = '" & strusername &
"'" & _
" And Password = " & "'" & strpassword & "'" & ";"
Set objRS = Server.CreateOb ject("ADODB.Rec ordSet")
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 1 2145
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("U sername"))
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.a sp" 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.as p"--> <!-- METADATA TYPE="typelib" FILE="C:\Progra m Files\Common Files\System\ad o\msado15.dll" -->
<% If Len(Request.For m("username") ) <> 0 Then Dim strusername, strpassword, sqlStmt, objRS strusername = Request.Form("u sername") strpassword = Request.Form("p assword") sqlStmt = "select * from [Password] where UserName = '" & strusername
& "'" & _ " And Password = " & "'" & strpassword & "'" & ";" Set objRS = Server.CreateOb ject("ADODB.Rec ordSet") 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 in the domain using AD.
ASP.NET applications run on other servers (not neccessary in domain) and
trying to use authentication server. How could this be done?
- Most response says you need to set MachineKey the same, but that alone
doesn't...
|
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
'Web.Security.FormsAuthentication.RedirectFromLoginPage' method
thanks,
Samuel
|
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 expire the login if the browser window is closed.
Is this normal behaviour? Is it something that i can circumvent. I would
prefer to allow users to login, and be logged in for a period of time before
|
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 the past in other
places, and while the help was much appreciated, it seemed everyone
just wanted to 'theoretically' explain how to do it, but when I tried
to do it myself, I couldn't login.
I want to simply pass the email address and password to...
|
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
"myDB" with a table "myUsers" with fields "Username" and "Password". I also
have the MySQL ODBC driver loaded with a DSN "dsnMySQL" setup.
First question is can someone direct me to a site or provide a sample code
for a login page that...
| |
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 service' at server level in Management Studio
express.
I use windows authentification.
Then i defined an user for my database which is associated to login 'Network
|
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 them to the appropriate page. So far, everything works fine. Myself and the user admin can login to the "Trform.asp" page OK without problem.
My question for you and your peers is I have 5 more users. Let's say A, B, C, D, and E. I want...
|
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 for the hidden textbox on the logout sub.. but how do i get round this? can i not change the value onclick?
<div id=Rightbody>
<!--<form id="RightBodyForm" name="RightbodyForm" method="post" action="Guestbook2.asp">-->
<%
Response.Expires...
|
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 "quick
login" control to appear in the banner at the top of my master page.
This control will just have a username and password textbox and login
button. I want to reuse all the same code. Plus, if the credentials
are incorrect, or additional...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |