I'm creating a web site which will have usernames and passwords. When someone inputs the correct id and password, I need it to bring up a web page with there name on it and the page which belongs to them only? I have created the database but I now need the
sql code? Can anyone help.
I have a log in page, so when you input your id i want it to go to a specific page related to that one id. Then if someone else logs in they will get the web page related to them. As for code, well thats the problem?? In the long run those pages will pick
up information from a database (hopefully). Hope this makes sense. Thanks.
Well, if you can give us information on how the tables are designed, we can probably figure out what you need to do. Since you aren't giving us a lot of information, we can only give you advice but can't really show you much.
I'm using .cshtml pages. I'm then trying to run SQL within that page. This then looks up the database to make sure the correct user is logged in. Hope this makes sense. Thanks.
I have, but I'm unable to find anything to make it work.
I'll explain what i'm trying to do. You open your web page and your asked for your username and password this will take you to a generic page. this page will then show information eg; your name, plus total amount of holiday you have. This information is
on a database. So... what Im trying to do is only show the information to the correct username. Hope this makes sense.
richt
Member
24 Points
15 Posts
User ID and Password
Apr 04, 2011 06:51 PM|LINK
Hi,
I'm creating a web site which will have usernames and passwords. When someone inputs the correct id and password, I need it to bring up a web page with there name on it and the page which belongs to them only? I have created the database but I now need the sql code? Can anyone help.
Thanks.
bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: User ID and Password
Apr 04, 2011 07:17 PM|LINK
Best thign to do is post the relevant code and how the database is laid out and we should be able to help.
richt
Member
24 Points
15 Posts
Re: User ID and Password
Apr 04, 2011 08:43 PM|LINK
I have a log in page, so when you input your id i want it to go to a specific page related to that one id. Then if someone else logs in they will get the web page related to them. As for code, well thats the problem?? In the long run those pages will pick up information from a database (hopefully). Hope this makes sense. Thanks.
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: User ID and Password
Apr 04, 2011 09:11 PM|LINK
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: User ID and Password
Apr 05, 2011 12:21 AM|LINK
dLcreations
Member
593 Points
244 Posts
Re: User ID and Password
Apr 05, 2011 01:06 PM|LINK
Is the Your Code in .aspx page <asp:Login ID="Login1" runat="server" onauthenticate="Login1_Authenticate"> </asp:Login>protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if (ValidateFunction(Login1.UserName, Login1.Password)) { Login1.Visible = false; Response.Write("Successfully LoggedIn"); } else { e.Authenticated = false; } } private bool ValidateFunction(string UserName, string Password) { bool BoolReturnValue = false; SqlConnection cn; cn = new SqlConnection(@"Data Source=Dhruval;Initial Catalog=HRMS;Uid=sa;Password=virsap;Connection TimeOut=0"); SqlCommand cmd; cn.Open(); cmd = new SqlCommand("select * from Login", cn); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { if ((UserName == rdr["UserName"].ToString()) & (Password == rdr["Password"].ToString())) { BoolReturnValue = true; } else { } rdr.Close(); return BoolReturnValue; } return BoolReturnValue; cn.Close(); }richt
Member
24 Points
15 Posts
Re: User ID and Password
Apr 05, 2011 08:39 PM|LINK
Thanks for this.
I'm using .cshtml pages. I'm then trying to run SQL within that page. This then looks up the database to make sure the correct user is logged in. Hope this makes sense. Thanks.
richt
Member
24 Points
15 Posts
Re: User ID and Password
Apr 05, 2011 08:46 PM|LINK
Mike,
I have used this upto a point. What I need to do now isn't in there which is a shame. Thanks for the help.
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: User ID and Password
Apr 05, 2011 09:14 PM|LINK
Have you looked at any of the template sites, such as the Starter Site? It has example code for the WebSecurity helpers.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
richt
Member
24 Points
15 Posts
Re: User ID and Password
Apr 05, 2011 09:30 PM|LINK
I have, but I'm unable to find anything to make it work.
I'll explain what i'm trying to do. You open your web page and your asked for your username and password this will take you to a generic page. this page will then show information eg; your name, plus total amount of holiday you have. This information is on a database. So... what Im trying to do is only show the information to the correct username. Hope this makes sense.