当用户登录时,只有该用户上传的图像会显示在下一页上 [英] When user login only image upload by that user display on next page

查看:43
本文介绍了当用户登录时,只有该用户上传的图像会显示在下一页上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了登录页面(signup.aspx),还开发了登录页面用户的登录页面(login.aspx).用户也上传了他们的图片,请修改登录代码,以便当用户仅登录该用户上传的图像时,显示在ex(infor.aspx)的下一页基本上,我想开发我的社交门户的个人资料页和登录页


我的数据库表名称是Table1

i develop the signup page(signup.aspx) and also login page(login.aspx) in signup page user also upload their picture please modify the login code in the way that when user login only image upload by that user display on next page for ex(infor.aspx)bascially i want to develop profile page and login page of my social portal


My database table name is Table1

ID int<br />
Eamil varchar(20) primary key<br />
password varchar(20)<br />
confirmpassword  varchar(20)<br />
Name  varchar(20)<br />
country varchar(20)<br />
Gender varchar(20)<br />
year varchar(20)<br />
month varchar(20)<br />
date varchar(20)<br />
Description varchar(20)<br />
PictureFile image



Signup.cs



Signup.cs

protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\WebSite4\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
        con1.Open();
        SqlCommand sc = new SqlCommand("Select Email from Table1", con1);
        SqlDataReader rd;
        rd = sc.ExecuteReader();
        while (rd.Read())
        {
            // Label25.Text = rd["Stid"].ToString();
            if (rd["Email"].ToString().Equals(TextBoxEmail.Text))
            {
                Response.Write("<script language=''javascript''>alert( ''Already Exsist '' )</script>");

                k = 1;

            }
        }
        con1.Close();
        if (k == 0)
        {
            string fileName = FileUpload1.PostedFile.FileName;
            int fileLength = FileUpload1.PostedFile.ContentLength;
            byte[] imageBytes = new byte[fileLength];
            FileUpload1.PostedFile.InputStream.Read(imageBytes, 0, fileLength);
            string connStr = ConfigurationManager.AppSettings["ConnStr"].ToString();
            using (SqlConnection conn = new SqlConnection(connStr))
            {

                string query1 = "insert into Table1(Email,Password,confirmPassword,Name,Country,Gender,Year,Date,Month,Description,PictureFile)values(''" + TextBoxEmail.Text + "'',''" + TextBox3.Text + "'',''" + TextBox4.Text + "'',''" + TextBoxName.Text + "'',''" + TextBox1.Text + "'',''" + DropDownList1.Text + "'',''" + DropDownList4.Text + "'',''" + DropDownList2.Text + "'',''" + DropDownList3.Text + "'',''" + TextBox2.Text + "'',@pictureFile)";
                SqlParameter[] prms = new SqlParameter[1];
                prms[0] = new SqlParameter("@pictureFile", SqlDbType.Image);
                prms[0].Value = imageBytes;
                using (SqlCommand cmd = new SqlCommand(query1, conn))
                {
                    cmd.Parameters.AddRange(prms);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }

                Response.Redirect("Login.aspx");

            }


login.cs


login.cs

protected void Button1_Click(object sender, EventArgs e)
   {
       SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\WebSite4\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
       con.Open();
       string query = "Select Password from Table1 Where Email=''" + TextBox2.Text + "''";
       SqlCommand com = new SqlCommand(query, con);
       SqlDataReader rd;
       rd = com.ExecuteReader();
       while (rd.Read())
       {
           s = rd[0].ToString();
       }
       con.Close();
       if (s == TextBox1.Text)
       {
           Session["Email"] = TextBox2.Text;
           Response.Redirect("information.aspx");
       }
       else
       {
           //Response.Redirect("home.aspx");
           Response.Write("<script language=''javascript''>alert( ''Invalid password or Email '' )</script>");

       }



[edit]主题被截断,添加了代码块-OriginalGriff [/edit]



[edit]Subject truncated, code blocks added - OriginalGriff[/edit]

推荐答案

我认为您对CodeProject的想法不正确.我们不会为他人编写代码-我们会帮助他们解决编码问题.您的问题是您希望其他人为您完成工作.我什至不需要调试器就可以弄清楚-您没有编程问题,您有编程问题.
I think you have the wrong idea about CodeProject. We don''t ewrite code for people - we help them with coding problems. Your problem is that you expect someone else to do your work for you. I didn''t even need the debugger to figure that out - you don''t have a programming problem, you have a problem programming.


我给了您所需的基本代码使用您发布的此问题的最新版本来执行此操作. 仅在用户登录时显示用户图像 [ ^ ]您要做的就是从数据库中获取适当的图像.

为什么不看看它,自己动手尝试呢?

没有人会在您的整个工作过程中牵手,为什么不现在就开始实际的开发呢?如果您确实被卡住,请问一个关于该特定点的问题,但是反复问同样的事情只会使人们对您感到恼火...(我怀疑JSOP已经有点不高兴了-他已经武装了牙齿,所以你不想把他*掉!)
I gave you the basic code you need to do this with the last version of this question you posted. display user image only when he logs in[^] All you had to do was get teh appropriate image from your database.

Why not look at it, and try it yourself?

Nobody is going to hold your hand through the whole of your working life, so why not give actual development a go now? If you do get stuck, then ask a question about that specific point, but repeatedly asking teh same thing is just going to get people annoyed with you... (I suspect that JSOP is already a little miffed - and he is armed to the teeth so you don''t want to p*ss him off!)


这篇关于当用户登录时,只有该用户上传的图像会显示在下一页上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆