About .NET Dave |  Advertise |  Contact Us |  FAQ |  Link2Me |  Webmasters |  Manage My Submissions
 
 
    Cool Stuff |  Hot Stuff! |  Newsletter |  What's New? |  Rotor Source Code
   
Peter's Data Entry Suite from PeterBlum.com

 Related Directories
 >> Form Handling   

  Validating Login website Rate this Resource  0  read reviews write a review report an error printer friendly version
This sample login.aspx authenticates the user against SQL Server.
Extended Description 
<%@ Import Namespace="System.Web.Security " %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>

<html>
<head>
<title>Login</title>
<script language="C#" runat=server>
void Login_Click(Object sender, EventArgs e) {
if(Page.IsValid)
{
SQLDataReader dr;

// Connect to the database
SQLConnection cn = new SQLConnection("server=localhost;
uid=ASPArticles;pwd=123;database=ASPArticles;");cn.Open();
// Create a command to get the question
SQLCommand cmdQuestion = new SQLCommand("SELECT Password;
FROM Users WHERE Email = '" + Email.Text + "'", cn);

// Create a datareader to get the question
cmdQuestion.Execute(out dr);
// Get the first row
if(dr.Read())
if(dr["Password"].ToString() == Password.Text)
CookieAuthentication.RedirectFromLoginPage(Email.Text, false);
else
Msg.Text = "Invalid password.";
else
Msg.Text = "Email address not found.";
}
}

</script>
</head>

<body>
<ASP:RequiredFieldValidator ControlToValidate="Password";
Display="Dynamic" ErrorMessage="You must enter a password." runat=server/>
<ASP:RequiredFieldValidator ControlToValidate="Email";
Display="Dynamic" ErrorMessage="You must enter your email address." runat=server/>
<asp:Label id="Msg" ForeColor="red" Font-Name="Verdana";
Font-Size="10" runat=server />
<form runat=server>
<table>
<tr>
<td><asp:label text="Email: " runat=server/></td>
<td><asp:textbox id="Email" runat=server /></td>
<td><asp:button id="btnLogin" Text="Login";
OnClick="Login_Click" runat=Server /></td>
</tr>
<tr>
<td><asp:label text="Password: " runat=server/></td>
<td><asp:textbox id="Password" TextMode="Password" runat=server /></td>
<td> </td>
</tr>
</table>
</form>

</body>
</html>

  archive.devx.com  related listings Total Views:6456 | Today:913 Total Hits:7956 | Today:518


Report an Error
Select the error
Your E-mail
(example: someone@yourisp.com)
Describe the Error
 
Protected by Clearscreen.SharpHIPTo prevent abuse from bots, please enter the text you see.:
 

 

 

 

 


Aspose – The .Net and Java component publisher


Aspose.Total – Your total component solution

ASP.NET Shopping Cart Software

Corporate Web Solutions .netCHARTING
  Hosted By:
  Check Out:
  #1 .NET Email
  .NET Email Validation
Back to Top   Last Updated: 4/23/2014 10:51:17 AM
© 2014www.123aspx.com All rights reserved. Terms of Use.   email comments: support@123aspx.com  or use our online form.