Click here to Skip to main content
16,004,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have username and password for login page. When i login for first time, i redirected to createprofile page where i have to submit all my details of my profile,education,skill etc. After submitting these details i logged out. But after logged out when i again login i have to redirect to my home page not to again createprofile page.

Suggest me the logic to redirect to home page for further login.
Here is my code for login into createprofile page:
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(str);
        SqlCommand cmd = new SqlCommand("select * from userlogin", con);
        con.Open();
        string decodpwd1 = DecodePassword(txtpwd.Text);
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            //Session["nm"] = txtuname.Text;
            //Session["uid"] = dr["user_id"].ToString();
            if (txtuname.Text == dr["user_name"].ToString() && decodpwd1 == dr["user_pwd"].ToString())
            {
               
                Response.Redirect("createprofile.aspx");
            }
            else
            {
                Label3.Visible = true;
                Label3.Text = "Invalid UserName/Password";
            }
        }

        con.Close();
        dr.Close();
    }
Posted
Updated 20-Oct-12 20:56pm
v2

Keep one field in your userlogin table as 'IsProfileCreated' - a bit field with default value 'false'.

Now, once someone logins, check the value of the field 'IsProfileCreated' and if found false direct to profile update page. On save of the profile data, set this field IsProfileCreated to true. Thus, next time when same user logs in, you have the data from this field that the profile is already set and you can redirect elsewhere.

Sample code:
C#
if(!IsProfileCreated)
{
  // Direct to Profile update page
}
else
{
  // Direct to home page
}
 
Share this answer
 
v2
Comments
NayakMamuni 21-Oct-12 3:24am    
thanks for this. but will you please explain with my code that how i have to mention this.
Sandeep Mewara 21-Oct-12 3:33am    
1. create Db field as I suggested
2. access the new field value post authentication
3. use the snippet I provided

Try!
NayakMamuni 21-Oct-12 5:02am    
thanks..its working
thanks again
Sandeep Mewara 21-Oct-12 5:29am    
Welcome.

Add a column to your userlogin table which tells you where to go from there.
I would make it numeric, and use an enum, which allows you to add destinations later.

In your login page, you check the enum and send the user to the appropriate page - when teh page is then complete, it updates the column with the future destination.

This also allows for special messages, "your password will expire soon", and so forth that you may want to add later.
 
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