01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Web;
05.
using
System.Web.UI;
06.
using
System.Web.UI.WebControls;
07.
using
System.Data;
08.
using
System.Data.SqlClient;
09.
using
System.Text;
10.
using
System.Security.Cryptography;
11.
namespace
User_Login
12.
{
13.
public
partial
class
Register : System.Web.UI.Page
14.
{
15.
//////** Password **///////
16.
public
string
EncMD5(
string
input)
17.
{
18.
MD5 md5Hashfc = MD5.Create();
19.
byte
[] data = md5Hashfc.ComputeHash(Encoding.Default.GetBytes(input));
20.
StringBuilder sBuilder =
new
StringBuilder();
21.
int
i = 0;
22.
for
(i = 0; i <= data.Length - 1; i++)
23.
{
24.
sBuilder.Append(data[i].ToString(
"x2"
));
25.
}
26.
return
sBuilder.ToString();
27.
}
28.
/////**End Password **//////
29.
protected
void
btnRegister_Click(
object
sender, EventArgs e)
30.
{
31.
SqlConnection objConn =
new
SqlConnection();
32.
SqlCommand objCmd =
new
SqlCommand();
33.
String strConnString, strSQL;
34.
35.
36.
37.
38.
strConnString =
"Data Source=OFF;Initial Catalog=customer;Integrated Security=True"
;
39.
objConn =
new
SqlConnection();
40.
objConn.ConnectionString = strConnString;
41.
objConn.Open();
42.
43.
strSQL =
"INSERT INTO register (username,lastname,password,address,tel,mobile,email) "
+
44.
" VALUES "
+
45.
" ('"
+
this
.txtUsername.Text +
"','"
+
this
.txtLastname.Text +
"','"
+ EncMD5(
"'"
+
this
.txtPassword.Text +
"'"
) +
"', "
+
46.
" '"
+
this
.txtAddress.Text +
"','"
+
this
.txtTel.Text +
"','"
+
this
.txtMobile.Text +
"','"
+
this
.txtEmail.Text +
"' )"
;