473,398 Members | 2,125 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,398 software developers and data experts.

Problem with login/index scripts

index:
<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Public strFullName As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Session("LoginNumber") Is Nothing Then
Response.Redirect("login.aspx")
Else
Dim strLoginQuery As String
strLoginQuery = "SELECT * FROM " & Session("TableType") & "
WHERE " & Session("PriKey") & "='" & Session("LoginNumber")
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dsRead As OleDbDataReader

Dim strConn As String
strConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
"C:\Inetpub\wwwroot\Styles\db\styles2k3.mdb;"
conn = New OleDbConnection(strConn)
comm = New OleDbCommand(strLoginQuery, conn)
dsRead = comm.ExecuteReader(CommandBehavior.CloseConnection )
While dsRead.Read()
If Session("TableType") = "FACTORIES" Then
strFullName = dsRead("FACTORY_NAME")
Else
strFullName = dsRead(Session("Prefix") & "FNAME") &
" " & dsRead(Session("Prefix") & "LNAME")
End If
End While
dsRead.Close()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="StyleSheet" type="text/css" href="css/styles.css" />
<title>Welcome <%=strFullName%></title>
</head>
<body>
</body>
</html>
login:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
Public strErrMessage As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim strLogin As String
Dim strPass As String

strLogin = Request.Form("txtLogin")
strPass = Request.Form("txtPassword")
If (strLogin <"" And strPass <"") Then
Dim strTable As String
Dim strTable2 As String
Dim strPrefix As String
Dim strPrefix2 As String
Dim strPrefix3 As String

strTable = ""
strTable2 = ""
strPrefix = ""
strPrefix2 = ""
strPrefix3 = ""
Select Case Request.Form("RadioButtonList1").ToString()
Case "Salesman"
strTable = "SALESLOGINS"
strTable2 = "SALESMEN"
strPrefix = "SL_"
strPrefix2 = "S_"
strPrefix3 = "SALESMAN_"
Case "Customer"
strTable = "CUSTLOGINS"
strTable2 = "CUSTOMERS"
strPrefix = "CL_"
strPrefix2 = "C_"
strPrefix3 = "CUSTOMER_"
Case "Supplier"
strTable = "FACTORYLOGINS"
strTable2 = "FACTORIES"
strPrefix = "FL_"
strPrefix2 = "F_"
strPrefix3 = "FACTORY_"
End Select
Dim conStr As String
Dim strQueryLogins As String
strQueryLogins = "SELECT TOP 1 FROM " & strTable & " WHERE "
& strPrefix & "LOGIN='" & strLogin & "' AND " & strPrefix & "PASSWORD='"
& strPass & "'"

conStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
"C:\Inetpub\wwwroot\Styles\db\styles2k3.mdb;"
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim objReader As OleDbDataReader

conn = New OleDbConnection(conStr)
conn.Open()
comm = New OleDbCommand(strQueryLogins, conn)
objReader = comm.ExecuteReader(CommandBehavior.CloseConnection )
If objReader.HasRows() Then
While objReader.Read()
Session("LoginNumber") = objReader(strPrefix2 & "ID")
Session("PriKey") = strPrefix3 & "ID"
Session("TableType") = strTable2
Session("Prefix") = strPrefix3
End While
Response.Redirect("index.aspx")
Else
strErrMessage = "Error: invalid username/password, try
again"
End If
objReader.Close()

End If
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Login</title>
<link rel="StyleSheet" type="text/css" href="css/styles.css" />
</head>
<body>
<% If (Len(Trim(strErrMessage)) 0) Then
Response.Write("<font color=red>" & strErrMessage & "</font>")
End If
%>
<h3>Login to website:</h3>
<form id="frmLogin" runat="server" action="login.aspx">
<div>
<asp:Label ID="Label1" runat="server" Text="User ID:"
Width="57px"></asp:Label>
<asp:TextBox ID="txtLogin" runat="server"></asp:TextBox><br />
<asp:Label ID="Label2" runat="server" Text="Password:"
Width="56px"></asp:Label>
<input id="txtPassword" type="password" /><br />
<br />
Are you logging in as a:<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="Customer"></asp:ListItem>
<asp:ListItem Value="Salesman"></asp:ListItem>
<asp:ListItem Value="Supplier"></asp:ListItem>
</asp:RadioButtonList><br />
<asp:Button ID="btnLogin" runat="server" Text="Login" />
<asp:Button ID="btnReset" runat="server" Text="Reset"
UseSubmitBehavior="False" /><br />

</div>
</form>
</body>
</html>

The index redirects fine on the first one, but when I login, it doesn't
seem to redirect me back to the right page (index.aspx)
Aug 24 '06 #1
0 1107

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

Similar topics

6
by: Rob Long | last post by:
Hey, I've written a custom HTML library using many PHP scripts as seperate files (just like I'd do a java project) and I'm having some problems where I'm including scripts in different...
7
by: Dan | last post by:
I was trying to troubleshoot a login page that doesn't work - it keeps saying the login/password is missing - when my tracing discovered this peculiar behavior. register_globals is off, so at...
3
by: neilphan | last post by:
Hi Guys, Please HELP! I'm new to PHP and would like to get your professional help! I"m writing simple and small login app using php session variable. I have 3 php scripts. The first is just a...
0
by: Moluske | last post by:
The web site was on another server i switch to a new one but this server hav now PHP Safe Mode to ON so i get error when creating thumbnail. I cant put PHP Safe mode to OFF. is ther any thing i...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
1
by: thecoolone | last post by:
I have an index.aspx page containing a button and the code in btn click is private void Button1_Click(object sender, System.EventArgs e) { if(User.Identity.IsAuthenticated) {...
0
by: shineyang | last post by:
Dear all: Who is kind to help me about the following problem. Why cannot log the remote node by using Net::Telent #################################### The following is normal to the process...
5
by: muppetjones | last post by:
I'm really new to the whole networking side of things, so I don't know the backend very well. I wrote a series of PHP/AJAX scripts to allow a user to create a login account, but apparently my script...
13
by: Apostle | last post by:
Hi all, after thinking for sometimes, I thought it will be great opportunity to learn if I will start from scratch and build my own register/login system. Here is the thread that I will be posting...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.