About .NET Dave |  Advertise |  Contact Us |  FAQ |  Link2Me |  Webmasters |  Manage My Submissions
    Cool Stuff |  Hot Stuff! |  Newsletter |  What's New? |  Rotor Source Code
Aspose – The .Net and Java component publisher

 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" %>

<script language="C#" runat=server>
void Login_Click(Object sender, EventArgs e) {
SQLDataReader dr;

// Connect to the database
SQLConnection cn = new SQLConnection("server=localhost;
// 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["Password"].ToString() == Password.Text)
CookieAuthentication.RedirectFromLoginPage(Email.Text, false);
Msg.Text = "Invalid password.";
Msg.Text = "Email address not found.";


<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>
<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>
<td><asp:label text="Password: " runat=server/></td>
<td><asp:textbox id="Password" TextMode="Password" runat=server /></td>
<td> </td>


  archive.devx.com  related listings Total Views:6575 | Today:1032 Total Hits:8021 | Today:583

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.:





Peter's Data Entry Suite from PeterBlum.com

telerik r.a.d.Suite

Corporate Web Solutions .netCHARTING

ASP.NET Shopping Cart Software
  Hosted By:
  Check Out:
  #1 .NET Email
  .NET Email Validation
Back to Top   Last Updated: 7/4/2015 10:56:16 AM
© 2015www.123aspx.com All rights reserved. Terms of Use.   email comments: support@123aspx.com  or use our online form.