protected void Page_Load(object sender, EventArgs e) { loginBll eml = new loginBll(); if (Request["Email"] != null) { ValidatedCode v = new ValidatedCode(); string code = v.CreateVerifyCode(); Session["EmailCode"] = code; string a = eml.SendMails(Request["Email"], "远哈注册", code, 0, 2, "null"); Response.Clear(); Response.ContentType = "text/plain"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(a); Response.End(); } else if (Request["Validatedcode"] != null) { string vCode = Session["EmailCode"].ToString(); string a = vCode.ToUpper() == Request["Validatedcode"].Trim().ToUpper() ? "true" : "false"; Response.Clear(); Response.ContentType = "text/plain"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(a); Response.End(); } }
public bool loginCheck(loginBll l) { bool isSuccess = false; SqlConnection con = new SqlConnection(myconstring); try { string sql = "Select * from Users where username=@username AND password = @password AND user_type=@user_type"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@username", l.username); cmd.Parameters.AddWithValue("@password", l.password); cmd.Parameters.AddWithValue("@user_type", l.Usertype); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } return(isSuccess); }