i've problem with login page.i need some guides or example coding to help me. i successfully create simple login page rite now n now i want adds some features based on accesslevel. i don't wanna using and i really don't know how to use roles based..so i really needs ur help..here my simple code..hope u can help me guys..
here my code:
Default.aspx - <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="test._Default" %>
-
-
<!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>Untitled Page</title>
-
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
-
<meta name="CODE_LANGUAGE" content="C#">
-
<meta name="vs_defaultClientScript" content="JavaScript">
-
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
-
</head>
-
<body>
-
-
<form id="frmlogin" method="post" runat="server">
-
<table id="mainTable" border="0">
-
<tr>
-
<td>
-
<table class="t_border" id="loginTable" cellspacing="15" cellpadding="0">
-
<tr>
-
<td><b>Email:</b></td>
-
<td><asp:textbox id="txtUserName" runat="server" width="160px"></asp:textbox>
-
<asp:requiredfieldvalidator id="rvUserValidator" runat="server" controltovalidate="txtUserName" errormessage="You must supply a Username!"
-
display="None"></asp:requiredfieldvalidator></td>
-
</tr>
-
<tr>
-
<td><b>Password: </b></td>
-
<td><asp:textbox id="txtPassword" runat="server" width="160px" TextMode="Password" ></asp:textbox>
-
<asp:requiredfieldvalidator id="rvPasswordValidator" runat="server" controltovalidate="txtPassword" errormessage="Empty Passwords not accepted"
-
display="None"></asp:requiredfieldvalidator></td>
-
</tr>
-
<tr>
-
<td align="center" colspan="2"><asp:button id="cmdSubmit" runat="server" text="Submit" borderstyle="Solid" OnClick="cmdSubmit_Click"></asp:button></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<table id="messageDisplay">
-
<tr>
-
<td><asp:validationsummary id="Validationsummary1" runat="server" width="472px" displaymode="BulletList"></asp:validationsummary></td>
-
</tr>
-
</table>
-
-
</td>
-
</tr>
-
</table>
-
-
</form>
-
<asp:label id="lblMessage2" runat="server" width="288px" font-bold="True" font-italic="True"
-
font-size="Medium" forecolor="#C00000"></asp:label> <br />
-
<br />
-
-
</body>
-
</html>
-
-
-
Default.aspx.cs
-
public partial class _Default : System.Web.UI.Page
-
{
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
-
}
-
-
/* references from 1. http://www.programmingtalk.com/archive/index.php/t-2066.html
-
* 2. http://www.daniweb.com/forums/thread24148.html */
-
protected void cmdSubmit_Click(object sender, EventArgs e)
-
{
-
-
if (Page.IsValid)
-
{
-
if (DBConnection(txtUserName.Text, txtPassword.Text))
-
{
-
Session["name"] = txtUserName.Text;
-
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);
-
Response.Redirect("home.aspx");
-
if (accesslevel = 1)
-
{
-
Response.Redirect("home2.aspx");
-
}
-
else if (accesslevel = 2)
-
{
-
Response.Redirect("home3.aspx");
-
}
-
}
-
else
-
{
-
lblMessage2.Text = "Account information is incorrect!";
-
}
-
}
-
-
}
-
-
private bool DBConnection(String txtUserName, String txtPassword)
-
{
-
bool authenticated;
-
OdbcParameter mail;
-
OdbcParameter pswd;
-
//OdbcParameter accesslevel;
-
string myscalar;
-
-
OdbcConnection myConn = new OdbcConnection(ConfigurationManager.ConnectionStrings["hrTraining"].ConnectionString);
-
OdbcCommand cmd = new OdbcCommand("SELECT email, password, name, id, userlevel FROM hris WHERE (email = '" + txtUserName + "' AND password = '" + txtPassword + "')", myConn);
-
-
mail = cmd.Parameters.Add("?email", OdbcType.Char, 40);
-
mail.Value = txtUserName;
-
-
pswd = cmd.Parameters.Add("?password", OdbcType.VarChar, 40);
-
pswd.Value = txtPassword;
-
-
//accesslevel = cmd.Parameters.Add("?userlevel", OdbcType.Int);
-
-
myConn.Open();
-
//cmd.ExecuteNonQuery();
-
-
OdbcDataReader reader = cmd.ExecuteReader();
-
-
if (reader.Read())
-
{
-
myscalar = cmd.ExecuteScalar();
-
Session["userID"] = myscalar;
-
authenticated = true;
-
}
-
else
-
{
-
authenticated = false;
-
}
-
-
reader.Close();
-
myConn.Close();
-
myConn.Dispose();
-
-
return authenticated;
-
}
-
}
2 1236
if (reader.Read())
{
myscalar = cmd.ExecuteScalar();
Session["userID"] = myscalar;
authenticated = true;
}
stort the access level in database and retreave level from database ,we can get user name from texrbox itself no need to go and get it from database
if (reader.Read())
{
myscalar = cmd.ExecuteScalar();
Session["userID"] = myscalar;
authenticated = true;
}
stort the access level in database and retreave level from database ,we can get user name from texrbox itself no need to go and get it from database
hi bala2it4u..
i think myb u misunderstood what exactly i want here..let me give some brief to u..since user want to login, they should key in their email and password..n after dats, i want make their name appear on every page..dats the problem now..i dunno how to call the username itself..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: William C. White |
last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using
cURL? Our website is hosted on a shared drive and the webhost company
doesn't installed additional software (such as cURL)...
|
by: Albert Ahtenberg |
last post by:
Hello,
I don't know if it is only me but I was sure that header("Location:url")
redirects the browser instantly to URL, or at least stops the execution of
the code. But appearantely it continues...
|
by: James |
last post by:
Hi,
I have a form with 2 fields.
'A'
'B'
The user completes one of the fields and the form is submitted.
On the results page I want to run a query, but this will change
subject to which...
|
by: Ollivier Robert |
last post by:
Hello,
I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9
system. The link succeeds but everytime I try to run php, I get a SEGV from
inside the libcnltsh.so library.
...
|
by: Richard Galli |
last post by:
I want viewers to compare state laws on a single subject.
Imagine a three-column table with a drop-down box on the top. A viewer
selects a state from the list, and that state's text fills the...
|
by: Albert Ahtenberg |
last post by:
Hello,
I have two questions.
1. When the user presses the back button and returns to a form he filled
the form is reseted. How do I leave there the values he inserted?
2. When the...
|
by: inderjit S Gabrie |
last post by:
Hi all
Here is the scenerio ...is it possibly to do this...
i am getting valid course dates output on to a web which i have designed
....all is okay so far , look at the following web url
...
|
by: Jack |
last post by:
Hi All,
What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g.
select x from y where z=:parameter
Which in asp/jsp would be followed by some statements to bind a value...
|
by: Sandwick |
last post by:
I am trying to change the size of a drawing so they are all 3x3.
the script below is what i was trying to use to cut it in half ... I
get errors.
I can display the normal picture but not the...
|
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...
|
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: 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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
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...
|
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 ...
| |