完成用户注册、登录页面,实现数据的真实操作。
2011-09-14 22:34
736 查看
编写小九九:
protected void Page_Load(object sender, EventArgs e)
{
HtmlTable table = new HtmlTable();
for (int i = 1; i <= 9; i++)
{
HtmlTableRow row = new HtmlTableRow();
for (int j = 1; j <=i; j++)
{
HtmlTableCell cell = new HtmlTableCell();
cell.InnerText = j + "*" + i + "=" + j * i;
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
table.Width = "100%";
table.CellSpacing = 0;
table.CellPadding = 10;
table.Border = 1;
table.BorderColor = "#000000";
this.p1.Controls.Add(table);
}
注册:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnTClick(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "server=张海涛;integrated Security=true;Initial Catalog=ASP.NET注册";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
string a;
if (Radio1.Checked)
{
a = "男";
}
else
{
a = "女";
}
string filename=File1.PostedFile.FileName;
filename=DateTime.Now.Ticks.ToString()+filename.Substring(filename.LastIndexOf("."));
//this.File1.PostedFile.SaveAs(Server.MapPath("upload")+"\\"+fillname);
this.File1.PostedFile.SaveAs(Server.MapPath("upload")+"\\"+filename);
cmd.CommandText = "insert into Login(Name,Sex,Password,Image) values ('" + this.name.Value + "','" + a + "','" + this.Password1.Value + "','" + filename + "')";
SqlDataReader myreader = cmd.ExecuteReader();
con.Close();
this.Response.Write("注册成功");
//StringBuilder sb = new StringBuilder();
//sb.Append("用户名是:").Append(this.name.Value);
//sb.Append("<br/>");
//sb.Append("密码是:").Append(this.Password1.Value);
//sb.Append("<br/>");
//sb.Append("性别是:");
//if (Radio1.Checked)
//{
// sb.Append("男");
//}
//else
//{
// sb.Append("女");
//}
//sb.Append("<br/>");
//string fillname=this.File1.PostedFile.FileName;
//fillname=DateTime.Now.Ticks.ToString()+fillname.Substring(fillname.LastIndexOf("."));
//this.File1.PostedFile.SaveAs(Server.MapPath("upload")+"\\"+fillname);
//sb.Append("头像:");
//sb.Append("<img src=\"upload/"+fillname+"\"/>");
//this.divResult.InnerHtml=sb.ToString();
}
}
登陆:
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;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDClick(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=张海涛;integrated Security=true;Initial Catalog=ASP.NET注册";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "mp_login3";
SqlParameter Pname = new SqlParameter("@Name", SqlDbType.VarChar, 10, "Name");
Pname.Direction = ParameterDirection.Input;
Pname.Value = this.Text1.Value.Trim();
cmd.Parameters.Add(Pname);
SqlParameter PSex = new SqlParameter("@Sex", SqlDbType.VarChar, 50, "Sex");
PSex.Direction = ParameterDirection.Output;
cmd.Parameters.Add(PSex);
SqlParameter PPassword = new SqlParameter("@Password", SqlDbType.VarChar, 50, "Password");
PPassword.Direction = ParameterDirection.Output;
cmd.Parameters.Add(PPassword);
SqlParameter PImage = new SqlParameter("@Image", SqlDbType.VarChar, 50, "Image");
PImage.Direction = ParameterDirection.Output;
cmd.Parameters.Add(PImage);
conn.Open();
int a = cmd.ExecuteNonQuery();
if (this.Text1.Value == cmd.Parameters["@Name"].Value.ToString().Trim() && this.Text2.Value == cmd.Parameters["@Password"].Value.ToString().Trim())
{
Response.Write("用户名是:.Value.ToString]" + cmd.Parameters["@Name"].Value.ToString());
Response.Write("性别是:.Value.ToString]" + cmd.Parameters["@Sex"].Value.ToString());
Response.Write("<img src=\"upload/" + cmd.Parameters["@Image"].Value.ToString() + "\"/>");
//头像是:
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
HtmlTable table = new HtmlTable();
for (int i = 1; i <= 9; i++)
{
HtmlTableRow row = new HtmlTableRow();
for (int j = 1; j <=i; j++)
{
HtmlTableCell cell = new HtmlTableCell();
cell.InnerText = j + "*" + i + "=" + j * i;
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
table.Width = "100%";
table.CellSpacing = 0;
table.CellPadding = 10;
table.Border = 1;
table.BorderColor = "#000000";
this.p1.Controls.Add(table);
}
注册:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnTClick(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "server=张海涛;integrated Security=true;Initial Catalog=ASP.NET注册";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
string a;
if (Radio1.Checked)
{
a = "男";
}
else
{
a = "女";
}
string filename=File1.PostedFile.FileName;
filename=DateTime.Now.Ticks.ToString()+filename.Substring(filename.LastIndexOf("."));
//this.File1.PostedFile.SaveAs(Server.MapPath("upload")+"\\"+fillname);
this.File1.PostedFile.SaveAs(Server.MapPath("upload")+"\\"+filename);
cmd.CommandText = "insert into Login(Name,Sex,Password,Image) values ('" + this.name.Value + "','" + a + "','" + this.Password1.Value + "','" + filename + "')";
SqlDataReader myreader = cmd.ExecuteReader();
con.Close();
this.Response.Write("注册成功");
//StringBuilder sb = new StringBuilder();
//sb.Append("用户名是:").Append(this.name.Value);
//sb.Append("<br/>");
//sb.Append("密码是:").Append(this.Password1.Value);
//sb.Append("<br/>");
//sb.Append("性别是:");
//if (Radio1.Checked)
//{
// sb.Append("男");
//}
//else
//{
// sb.Append("女");
//}
//sb.Append("<br/>");
//string fillname=this.File1.PostedFile.FileName;
//fillname=DateTime.Now.Ticks.ToString()+fillname.Substring(fillname.LastIndexOf("."));
//this.File1.PostedFile.SaveAs(Server.MapPath("upload")+"\\"+fillname);
//sb.Append("头像:");
//sb.Append("<img src=\"upload/"+fillname+"\"/>");
//this.divResult.InnerHtml=sb.ToString();
}
}
登陆:
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;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDClick(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=张海涛;integrated Security=true;Initial Catalog=ASP.NET注册";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "mp_login3";
SqlParameter Pname = new SqlParameter("@Name", SqlDbType.VarChar, 10, "Name");
Pname.Direction = ParameterDirection.Input;
Pname.Value = this.Text1.Value.Trim();
cmd.Parameters.Add(Pname);
SqlParameter PSex = new SqlParameter("@Sex", SqlDbType.VarChar, 50, "Sex");
PSex.Direction = ParameterDirection.Output;
cmd.Parameters.Add(PSex);
SqlParameter PPassword = new SqlParameter("@Password", SqlDbType.VarChar, 50, "Password");
PPassword.Direction = ParameterDirection.Output;
cmd.Parameters.Add(PPassword);
SqlParameter PImage = new SqlParameter("@Image", SqlDbType.VarChar, 50, "Image");
PImage.Direction = ParameterDirection.Output;
cmd.Parameters.Add(PImage);
conn.Open();
int a = cmd.ExecuteNonQuery();
if (this.Text1.Value == cmd.Parameters["@Name"].Value.ToString().Trim() && this.Text2.Value == cmd.Parameters["@Password"].Value.ToString().Trim())
{
Response.Write("用户名是:.Value.ToString]" + cmd.Parameters["@Name"].Value.ToString());
Response.Write("性别是:.Value.ToString]" + cmd.Parameters["@Sex"].Value.ToString());
Response.Write("<img src=\"upload/" + cmd.Parameters["@Image"].Value.ToString() + "\"/>");
//头像是:
}
}
}
相关文章推荐
- andriod———1.实现原生登录注册。 2.首页完成商品列表展示点击相对应的商品ID进入商品详情 3.商品详情页面展示数据,点击加入购物车进入购物车页面 4.购物车页面完成购物车编辑,删除,功能
- 如何实现共享软件网络授权认证,包括注册新用户、登录、修改密码等操作
- 淘淘商城系列——单点登录之用户注册页面实现
- 如何实现共享软件网络授权认证,包括注册新用户、登录、修改密码等操作
- JSP作业3 - 使用JSP实现简单的用户登录注册页面
- 制作login.jsp页面,要求实现提供用户登陆的界面, 用户通过该界面输入用户名(控件名userName)和密码(控件名password), 然后点击“登录”按钮实现登陆操作.
- 1 完成登录页面(到记事本文件进行密码和用户名的验证)。 2 完成 用户注册页面(将注册信息显示在本页面 div 中)。
- JSP作业4 - 使用JSP+JavaBean+Servlet实现用户登录注册页面
- 如何实现共享软件网络授权认证,包括注册新用户、登录、修改密码等操作
- 实现用户注册功能:用servlet验证提交的数据是否合法,不合法返回注册页面,并提示出错。
- eShop电子商城的SSH实现的用户模块(1)登录和注册配置文件和页面关键代码(V...
- 集合框架_用户登录注册案例详细分析和分包的实现、用户基本描述类和用户操作接口的实现、用户操作类的具体实现、用户测试类的实现、加入猜数字小游戏
- 采用php与Mysql数据库完成用户注册登录等操作
- 简易 的QQ APP登录以及注册页面的实现
- 使用Forms Authentication实现用户注册、登录 (一)基础知识
- Yii开发系列2:实现用户注册验证登录
- node.js实现登录注册页面
- 使用php完成一个用户注册以及管理的demo(php实现单文件与多文件的上传)
- Unity C# 连接SQL Server数据库,实现获取和添加登录注册的用户列表
- Laravel框架实现修改登录和注册接口数据返回格式的方法