Click here to Skip to main content
15,918,168 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello!!

I have two table in my database. one is memberinfor table & another is userinfo table.

In Memberinfor table i have 5 column (member_id,member_name,user_id,branch,status)
In userinfo table i have 5 columns (User_id,User_name,password,mailid,Branch)

I also have a log in page & through this page i can logged in in my web project.
I can create new members through add member page & this member information also insert in my memberinfo table.

Now if any user logged in (through username & password) & create any new member then how to tag this user id in my memberinfo table??? please help me with code & example...
Posted
Comments
PrashantSonewane 16-Apr-13 0:51am    
Have you tried something? Can you give code block you have tried and tell us whats not working?
prodipjsr 16-Apr-13 0:55am    
No, actually, i have no idea about this..can u give me any idea??

on your login page when you are validating user authentication, save userid in Session and use that id through out project for manipulating data and info on pages
 
Share this answer
 
Comments
prodipjsr 16-Apr-13 2:11am    
please give little example with code..i have create session in my log in page..
[no name] 16-Apr-13 2:57am    
session.add("userid","1") for adding; than session["userid"] will return value, use that value to insert in memebrinfo table where ever u are using insert method on pages in project,
prodipjsr 16-Apr-13 3:26am    
Thanx for ur idea..it is work,,but i want to some different...

I have add the code in login.aspx page:
if (result >= 1)
{
Session["userName"] = txtUserName.Text.ToString().Trim();
Response.Redirect("Default.aspx");
}
else
lblMsg.Text = "Incorrect Username or Password";

===============
And i also add this code to my members pare.
string userid = Session["userName"].ToString();
myCommand.Parameters.Add("@userid", System.Data.SqlDbType.VarChar, 10).Value = userid;

In these code i can insert user name in my memberinfo table..but i want to insert only user_code, not user_name..how i do this??
[no name] 16-Apr-13 3:41am    
how ur getting result in ur code, create a session["userid"] = result it will work if ur retriving userid from database
prodipjsr 16-Apr-13 3:57am    
can i use this code?
session["userid"]= "select User_id from userinfo where user_name=session["Username"]";

i am not sure..can i use it or some thing others??
Hello sir,

please give me the idea how can i do this========
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-May-13 2:10am    
Not an answer, should be removed.
—SA

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