My checks


SUBMITTED BY: Guest

DATE: March 11, 2014, 7:52 p.m.

FORMAT: C#

SIZE: 3.1 kB

HITS: 768

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.OleDb;
  8. using System.Web.Services;
  9. using System.Data;
  10. public partial class _Default : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. }
  15. protected void txtName_TextChanged(object sender, EventArgs e)
  16. {
  17. }
  18. protected void Send_Click(object sender, EventArgs e)
  19. {
  20. //Connect connection = new Connect("/App_Data/Database.accdb");
  21. // string queryString = "INSERT users.[userName], users.[password], users.[email] FROM users";
  22. ////queryString+= string.format("{0}')"
  23. //OleDbCommand command = new OleDbCommand(queryString);
  24. // connection.TakeAction(command);
  25. string name = txtName.Text;
  26. string pass = txtPassword.Text;
  27. string email = txtEmail.Text;
  28. string address = txtAddress.Text;
  29. Error1.Text = "You did not fill the following registration fields: ";
  30. bool finalcheck = true;
  31. if (name == "")
  32. {
  33. Error1.Visible = true;
  34. Error1.Text = Error1.Text + " Name.";
  35. finalcheck = false;
  36. }
  37. if (pass == "")
  38. {
  39. Error1.Visible = true;
  40. Error1.Text = Error1.Text + " Password.";
  41. finalcheck = false;
  42. } if (email == "")
  43. {
  44. Error1.Visible = true;
  45. Error1.Text = Error1.Text + " Email.";
  46. finalcheck = false;
  47. } if (address == "")
  48. {
  49. Error1.Visible = true;
  50. Error1.Text = Error1.Text + " Address.";
  51. finalcheck = false;
  52. }
  53. localhost.WebService w = new localhost.WebService();
  54. string check = "SELECT * FROM users WHERE userName = '" + name + "'";
  55. DataTable dt = w.GetConn(check);
  56. string check1 = "SELECT * FROM users WHERE email = '" + email + "'";
  57. DataTable dt1 = w.GetConn(check1);
  58. if (dt.Rows.Count > 0)
  59. {
  60. Error2.Text = "This username already exists, please choose a different one";
  61. finalcheck = false;
  62. }
  63. else
  64. {
  65. Error2.Text = "";
  66. }
  67. if (dt1.Rows.Count > 0)
  68. {
  69. Error3.Text = "This email already exists, please use a different one";
  70. finalcheck = false;
  71. }
  72. else
  73. {
  74. Error3.Text = "";
  75. }
  76. if (finalcheck == true)
  77. {
  78. Error1.Visible = false;
  79. string salt = w.RandomString();
  80. string hash = w.getHashSha256(salt + pass);
  81. w.Insert(name, hash, email, address, salt);
  82. Error3.Text = "You have successfully registered!";
  83. }
  84. }
  85. }

comments powered by Disqus