Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i make a login sytem which is included 2 form 1st form have 2text box username and password and 2nd from have 2 labels .... its is connected with database which included 2 tables 1 for username and password and 2table have name and phone# and both table are in relationship with forgein key...........i want that user give his user name and password and its name and phone# see in another form in those label which are there ...................plz help me plz
Posted
Comments
Rahul Rajat Singh 24-Nov-12 7:13am    
Web forms or windows application?
Arbaz Ali 24-Nov-12 13:02pm    
windows application

when user is login and he is valid user then store there user_id in sesstion. then redirect to next page and on page_load of page 2 write the following code

C#
Protected void Page_Load()
{
   If(Session["YourSessionName"] != null && Session["YourSessionName"] != "")
   {
      int userID = Convert.ToInt32(Session["YourSessionName"]);
      If(!IsPostBack)
        {
           // fetch the data from database and set the Text property of your label here
        }
   }
}


EDIT: Code formatting added.
 
Share this answer
 
v2
You need to pass Username and Password from 1Form to 2Form
Ex. In Form 1
Create object of 2Form and pass UserName and Password
C#
Form2 f = new Form(Username,Password);
     f.show();


In Form 2 create Constructor that have two parameter ie Username and Password

C#
string UserName="";
   string Password="";
   Public Form2(string UserName, string Password)
   {
        this.UseName = UserName;
        this.Password = Password;
        InitializeComponent();
   }


Also, In Form2 Load Event Run Following Query BUT MUST HAVE ONE UNIQUE CLOUMN IN BOTH TABLE
SQL
SELECT T1.USERNAME,T1.PASSWORD ,T2.NAME, T2.PHONE FROM TABLE1 T1 INNERJOIN TABLE2 T2 ON T1.ID = T2.ID WHERE T1.USERNAME="" AND T1.PASSWORD="";


Update above Query as per u r requirement

I hope this will be help for u

EDIT: code formatting added.
 
Share this answer
 
v2

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