Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to go into signup page from login page when i click onto signup



this is my code........loginusing System;
C#
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 Default2 : System.Web.UI.Page
{
   

    SqlConnection con = new SqlConnection("Data Source=...........;Initial Catalog=EmployeeDB;Integrated Security=True");


    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnlogin_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from information where Username=@Username and Password=@Password", con);
        cmd.Parameters.AddWithValue("@Username", TextBox1.Text);
        cmd.Parameters.AddWithValue("@Password", TextBox2.Text);
        SqlDataAdapter ad = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        ad.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            Session["Username"] = TextBox1.Text;

            Response.Redirect("Default3.aspx");
        }
        else
        {
            Label3.Visible = true;
            Label3.Text = "Invalid username&password....!!!";

        }
      
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default5.aspx");
    }
}






this is my sigup page..........


C#
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;

public partial class Default5 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=.........;Initial Catalog=EmployeeDB;Integrated Security=True");

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnsave_Click(object sender, EventArgs e)
    {
        con.Open();
        string qry = "insert into information values('" +TextBox1.Text + "','" + TextBox2.Text + "','"+TextBox3.Text+"','"+TextBox4.Text+"','"+TextBox5.Text+"')"; 
        SqlCommand cmd = new SqlCommand(qry,con);
        cmd.ExecuteNonQuery();
        con.Close();
    }
}
Posted
Updated 21-Mar-12 21:41pm
v2

1 solution

First off, don't store your passwords in clear text - it is a very bad idea from a security point of view. There are some notes here that will help: Password Storage: How to do it.[^]

Secondly, why are you doing all this manually? Why not use the Membership system, which will mean that you don't have to check for user logged in on each page, because it won't allow non-users access to the page in the first place? Introduction to Membership[^] It also provides all the common facilities...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900