| Author: Er. Ram Singh 27 Feb 2008 | Member Level: Gold | Rating: Points: 2 |
protected void Sign_In(object sender, ImageClickEventArgs e) { try {
Connection con = new Connection(); DataTable dt = new DataTable();
string str = "select * from LOGIN where LOGIN_USER_NAME= '" + Txt_User_Name.Value + "'" + " AND LOGIN_PASSWORD='" + Txt_Password.Value + "'"; dt = con.getDataTable(str); Session["reg_id"] = dt.Rows[0]["REG_ID"].ToString(); Session["user"] = dt.Rows[0]["LOGIN_USER_NAME"].ToString();
Response.Redirect("../Registration/summary.aspx?regid=" + dt.Rows[0]["REG_ID"] + "&field=" + dt.Rows[0]["LOGIN_FIELD"] + "&user=" + Txt_User_Name.Value);
} catch (Exception ex) { Response.Write(ex.Message); } }
|
| Author: swastik nath 27 Feb 2008 | Member Level: Silver | Rating: Points: 2 |
For the button click event verify if the username and password are valid then use another select statement to retrieve the Category from the database. next use IF condition to redirect the user to emplunch.aspx form if his category is employee or redirect it to Lunchdinner.aspx
do revert back to me if you have any concerns.
regards, Swastik Nath.
|
| Author: swastik nath 27 Feb 2008 | Member Level: Silver | Rating: Points: 2 |
Hi shahin, Let me tell you exactly what I did.. I created 3 forms .. Form 1=login.aspx. Form 2 = emplunch.aspx Form 3= lunchdinner.aspx
Now I put 3 controls on login.aspx. One textbox for username. One textbox for password. One button for checking functionality.
In button click event I wrote the following code which is very simple to understand ..
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New SqlConnection con.ConnectionString = "server=ibm37;database=tempdb;user id=sa;pwd=sa" Dim cmd As New SqlCommand("select category from tblcanteen where userid=(select userid from tblcanteen where name='" & TxtName.Text & "' and password='" & TxtPassword.Text & "')", con) Dim dr As SqlDataReader con.Open() dr = cmd.ExecuteReader If dr.Read Then If dr.Item("category").ToString = "emp" Then Response.Redirect("EmpLunch.aspx") Else Response.Redirect("Lunchdinner.aspx") End If Else LblMessage.Text = "invalid Username/Password" End If
con.Close()
End Sub
I am using userid as it's unique for every employee and depending upon his login info I am redirecting him to different forms. The userid will be retrieved by the select statement only if the username and password match. I hope your query is quite clear now..
Revert back to me if you have any concerns.
Regards, Swastik Nath.
|