Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.OleDb;
- using System.Data.SqlClient;
- using System.Security.Cryptography;
- using System.ComponentModel;
- using System.Text;
- public partial class Register : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- signUpFail.Visible = false;
- signUpSuccess.Visible = false;
- passwordFail.Visible = false;
- DEBUGMESSAGE.Visible = false;
- }
- protected void registerButton_Click(object sender, EventArgs e)
- {
- string IndvConnString = System.Configuration.ConfigurationManager.ConnectionStrings["LocalConnectionString"].ConnectionString;
- OleDbConnection IndvSignCon = new OleDbConnection(IndvConnString);
- IndvSignCon.Open();
- Type csType = this.GetType();
- // check to ensure that UserId keyed in is not being in used by other Customers
- OleDbCommand cmd;
- OleDbDataReader rdr;
- string strSQLSelect = "SELECT uEmail FROM Users ORDER BY uEmail";
- cmd = new OleDbCommand(strSQLSelect, IndvSignCon);
- rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- if (email_textbox.Text == (string)rdr["uEmail"])
- {
- signUpFail.Visible = true;
- IndvSignCon.Close();
- return;
- }
- const int MIN_LENGTH = 10;
- string password = password_textbox.Text;
- if (password.Length < MIN_LENGTH)
- {
- passwordFail.Visible = true;
- IndvSignCon.Close();
- return;
- }
- string sSourceData;
- byte[] tmpSource;
- byte[] tmpHash;
- sSourceData = password_textbox.Text;
- tmpSource = ASCIIEncoding.ASCII.GetBytes(sSourceData);
- //Compute Hash
- tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource);
- // insert new record
- string strSQLInsert = "INSERT INTO "
- + " Users (uName, uPass, uEmail, uNo, uEmerName, uEmerNo, uEmerRe)"
- + " VALUES (@name, @pw, @em, @hp, @emername, @emerhp, @emerrel)";
- cmd = new OleDbCommand(strSQLInsert, IndvSignCon);
- cmd.Parameters.AddWithValue("@name", name_textbox.Text);
- cmd.Parameters.Add("@pw", OleDbType.VarBinary, 64).Value = tmpHash;
- cmd.Parameters.AddWithValue("@em", email_textbox.Text);
- cmd.Parameters.AddWithValue("@hp", phone_textbox.Text);
- cmd.Parameters.AddWithValue("@emername", emerName_textbox.Text);
- cmd.Parameters.AddWithValue("@emerhp", emerNo_textbox.Text);
- cmd.Parameters.AddWithValue("@emerrel", emerRel_dropdown.Text);
- cmd.ExecuteNonQuery();
- IndvSignCon.Close();
- signUpSuccess.Visible = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement