---------------------------------registration cs----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class reg : System.Web.UI.Page
{
public static string CONN_STRING = ConfigurationManager.AppSettings["constr"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void submit_Click(object sender, EventArgs e)
{
if(password.Text==repassword.Text)
{
try {
SqlConnection con = new SqlConnection(CONN_STRING);
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from user_reg where us_userid='"+userid.Text+"'", con);
int cnt = Convert.ToInt32(cmd.ExecuteScalar());
if (cnt!=1 )
{
cmd = new SqlCommand("insert into user_reg (us_userid,us_name,us_password,us_designation,us_department,us_gender,us_address,us_emailid,us_mbn,us_regdate) values ('" + userid.Text + "','" + name.Text + "','" + password.Text + "','" + designation.Text + "','" + department.Text + "','" + gender.Text + "','" + address.Text + "','" + email.Text + "','" + mno.Text + "','" +System.DateTime.Today+ "')", con);
cmd.ExecuteNonQuery();
msg.InnerHtml = "inserted successfully";
con.Close();
}
else
{
msg.InnerHtml = "User already exist";
}
}
catch(Exception ex)
{
}
}
}
}
------------------------------------webconfig ---------------------
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="constr" value="Data Source=TAGORE-PC;Initial Catalog=library;Integrated Security=True;" ></add>
</appSettings>
</configuration>
-----------------------------------------login cs-------------------------
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class login : System.Web.UI.Page
{
public static string CONN_STRING = ConfigurationManager.AppSettings["constr"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try {
SqlConnection con = new SqlConnection(CONN_STRING);
con.Open();
SqlCommand cmd = new SqlCommand("insert into logintable values('" + Userid_login.Text + "','" + password_login.Text + "')", con);
int num = cmd.ExecuteNonQuery();
con.Close();
}
catch(Exception ex)
{
}
}
}
------------------------------------login aspx--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" EnableEventValidation="False" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="js/cloudflare.min.js"></script>
<link href="css/stylelg.css" rel="stylesheet" />
<link href="css/fdw-demo.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="container">
<div class="freshdesignweb-top"><h1><a href="http://www.freshdesignweb.com/">Online Library Management System</a></h1></div><div class="clr">
</div>
<header>
<h1><span><strong>Login Form</strong></span> </h1>
</header>
<div class="form">
<form id="contactform">
<p class="contact"><label for="email">Userid_login</label></p>
<asp:TextBox ID="Userid_login" runat="server" placeholder="User id" required="" ></asp:TextBox>
<p class="contact"><label for="password">password</label></p>
<asp:TextBox ID="password_login" runat="server" placeholder="password" required="" ></asp:TextBox>
<br><br>
<asp:Button ID="Button1" class="buttom" runat="server" Text="Submit" tabindex="5" OnClick="Button1_Click" />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="reg.aspx"><h5><span style="color:red">Go to SignUp</span></h5></asp:HyperLink>
<br>
</form>
</div>
</div>
</div>
</form>
</body>
</html>