Advertisement
Guest User

Untitled

a guest
Apr 12th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Security.Cryptography;
  8. using System.Text;
  9. using System.Text.RegularExpressions;
  10. using System.Net.Mail;
  11.  
  12. namespace WebApplication1
  13. {
  14.  
  15. public partial class index : System.Web.UI.Page
  16. {
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19.  
  20. }
  21.  
  22.  
  23. string userr;
  24. string emailr;
  25. protected void Button1_Click(object sender, EventArgs e)
  26. {
  27. SqlConnection conn = new SqlConnection();
  28. conn.ConnectionString =
  29. "Data Source=127.0.0.1;" +
  30. "Initial Catalog=Auth94;" +
  31. "User id=sa;" +
  32. "Password=Kadantte@93//**;";
  33.  
  34. string username = user.Text;
  35. string password = pass.Text;
  36. MD5 md5 = MD5.Create();
  37. byte[] result = md5.ComputeHash(Encoding.UTF8.GetBytes("2011"+password));
  38. StringBuilder hash = new StringBuilder();
  39. for (int i = 0; i < result.Length; i++)
  40. {
  41. hash.Append(result[i].ToString("X2"));
  42. }
  43.  
  44. hash.ToString();
  45. string passwordconf = passconf.Text;
  46. string elmail = email.Text;
  47. string emailconfe = emailconf.Text;
  48. string Captcha = Captchat.Text;
  49. conn.Open();
  50.  
  51. SqlCommand select1 = new SqlCommand("Select account,email from Account where account = '"+username+"' or email = '"+elmail+"'",conn);
  52.  
  53.  
  54. SqlDataReader rader = select1.ExecuteReader();
  55. while (rader.Read())
  56. {
  57.  
  58. userr = rader.GetSqlValue(0).ToString();
  59. emailr = rader.GetSqlValue(1).ToString();
  60. }
  61.  
  62. if (userr == username || emailr == elmail)
  63. {
  64.  
  65. Label1.Text = "Username or email already exists!";
  66. conn.Close();
  67. }
  68. else if (Captcha != Session["CaptchaValue"].ToString())
  69. {
  70. Label1.Text = "Wrong Captcha!";
  71. }
  72. else if (password != passwordconf) {
  73.  
  74. Label1.Text = "Password does not match!";
  75. }
  76. else if(elmail != emailconfe){
  77.  
  78. Label1.Text = "Email does not match!";
  79. }
  80. else if (!Regex.IsMatch(username, "^[a-zA-Z0-9]{4,15}$")) {
  81. Label1.Text = "The user name must be of letters and numbers only and not less than 4 characters and not more than 15 characters.";
  82. }
  83. else if (!Regex.IsMatch(password, "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^\\da-zA-Z]).{6,15}$")) {
  84. Label1.Text = "Password must be at least 6 letters and not more than 15 characters.";
  85. }
  86. else if (!Regex.IsMatch(elmail, "^[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9-]+\\.+[a-zA-Z]{1,5}$"))
  87. {
  88. Label1.Text = "Invalid email please type it correctly!";
  89. }
  90. else
  91. {
  92. conn.Close();
  93. conn.Open();
  94. 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);
  95. qaury.ExecuteNonQuery();
  96. Label1.Text = "Register success // TIPS : Never share your password! A GM will never ask you for your password.";
  97. }
  98. conn.Close();
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement