|
| login form session |
 |
Wed, 2 Apr 2008 22:20:56 +0000 |
my login form works so the user can access the next page in the website but i
would like to say welcome to the user when they login, i'm not to sure but i
think i need to use a session, below is the code i am using already could
someone help me append my code to welcome the user!??
thanks milsom <SCRIPTRunat="Server">
Sub Log_In (Src AsObject, Args As EventArgs)Dim DBConnection = New
OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _"Data Source="
& Server.MapPath("UserAccounts.mdb"))
DBConnection.Open()
Dim SQLString AsString = "SELECT Count(*) FROM Accounts " & _
"WHERE TheAccount = '" & Account.Text & "' " &
_
"AND ThePassword = '" & Password.Text & "'"Dim
DBCommand = New OleDbCommand(SQLString, DBConnection)Dim RecordCount AsInteger =
DBCommand.ExecuteScalar()
If RecordCount = 0 Then
Message.Text = "Incorrect Username or Password"
Else
Session.Contents("LoggedIn") =
TrueResponse.Redirect("LoggedIn.aspx")
EndIf
DBConnection.Close()
EndSub
</SCRIPT>
<formrunat="server">
Username:
<asp:TextBoxid="Account"Width="100px"Runat="Server&q
uot;/><br/>
Password:
<asp:TextBoxid="Password"TextMode="Password"Width="1
00px"Runat="Server"/><br/>
<asp:ButtonID="Button1"Text="Login"OnClick="Log_In&q
uot;Runat="Server"/><br/>
<asp:Labelid="Message"EnableViewState="False"ForeColor=&q
uot;#FF0000"Runat="Server"/>
</form>
|
| Post Reply
|
| Re: login form session |
 |
Thu, 3 Apr 2008 00:51:30 +0000 |
Session.Contents("LoggedIn") = True
Session("User") = Account.Text
DBConnection.Close()
Response.Redirect("LoggedIn.aspx")
Then:
LabelWelcome.Text = "Welcome " &
Server.HTMLEncode(Session("User"))
Close the connection before redirecting. Nothing after Response.Redirect() ever
gets executed.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|