Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Security.Cryptography;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Net.Mail;
- namespace WebApplication1
- {
- public partial class index : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- string userr;
- string emailr;
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlConnection conn = new SqlConnection();
- conn.ConnectionString =
- "Data Source=127.0.0.1;" +
- "Initial Catalog=Auth94;" +
- "User id=sa;" +
- "Password=Test552;";
- string username = user.Text;
- string password = pass.Text;
- MD5 md5 = MD5.Create();
- byte[] result = md5.ComputeHash(Encoding.UTF8.GetBytes("2011"+password));
- StringBuilder hash = new StringBuilder();
- for (int i = 0; i < result.Length; i++)
- {
- hash.Append(result[i].ToString("X2"));
- }
- hash.ToString();
- string passwordconf = passconf.Text;
- string elmail = email.Text;
- string emailconfe = emailconf.Text;
- string Captcha = Captchat.Text;
- conn.Open();
- SqlCommand select1 = new SqlCommand("Select account,email from Account where account = '"+username+"' or email = '"+elmail+"'",conn);
- SqlDataReader rader = select1.ExecuteReader();
- while (rader.Read())
- {
- userr = rader.GetSqlValue(0).ToString();
- emailr = rader.GetSqlValue(1).ToString();
- }
- if (userr == username || emailr == elmail)
- {
- Label1.Text = "Username or email already exists!";
- conn.Close();
- }
- else if (Captcha != Session["CaptchaValue"].ToString())
- {
- Label1.Text = "Wrong Captcha!";
- }
- else if (password != passwordconf) {
- Label1.Text = "Password does not match!";
- }
- else if(elmail != emailconfe){
- Label1.Text = "Email does not match!";
- }
- else if (!Regex.IsMatch(username, "^[a-zA-Z0-9]{4,15}$")) {
- Label1.Text = "The user name must be of letters and numbers only and not less than 4 characters and not more than 15 characters.";
- }
- else if (!Regex.IsMatch(password, "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^\\da-zA-Z]).{6,15}$")) {
- Label1.Text = "Password must be at least 6 letters and not more than 15 characters.";
- }
- else if (!Regex.IsMatch(elmail, "^[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9-]+\\.+[a-zA-Z]{1,5}$"))
- {
- Label1.Text = "Invalid email please type it correctly!";
- }
- else
- {
- conn.Close();
- conn.Open();
- SqlCommand qaury = new SqlCommand("INSERT [dbo].[Account] ([account], [password], [email], [password2], [block], [IP_user], [last_login_server_idx], [Admin], [point], [datePassword]) VALUES ('" +username+ "', '" +hash+ "', '" +elmail+ "', '" +hash+ "', 0, 'localhost', 1, 0, 0, '2018-10-20')", conn);
- qaury.ExecuteNonQuery();
- Label1.Text = "Register success // TIPS : Never share your password! A GM will never ask you for your password.";
- }
- conn.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement