public static string UserRegister(string userName, string email, string phone, string password) { //INSERT INTO dbo.userinfo VALUES ('中火锅', '123', '*****@*****.**', '110011','','') if (!isRegister(userName)) { return("-1");//重复 } else { publicFunction func = new publicFunction(); string passw = func.Md5encryption(password); string sql = "INSERT INTO dbo.userinfo VALUES ('" + userName + "', '" + passw + "', '" + email + "', '" + phone + "','','')"; DbMybbsEntities entit = new DbMybbsEntities(); int cont = entit.ExecuteStoreCommand(sql); if (cont >= 1) { return("1");// 成功 } else { return("0");//失败 } } }
public static bool userLogn(string userName, string pawd) { //select * from dbo.userinfo where dbo.userinfo.UID ='100001' and dbo.userinfo.password='******' publicFunction publicfunc = new publicFunction(); string md5pawd = publicfunc.Md5encryption(pawd).ToString(); string sql = "select * from dbo.userinfo where dbo.userinfo.username ='******' and dbo.userinfo.password='******'";; try { DbMybbsEntities entit = new DbMybbsEntities(); List <userinfo> uselist = entit.ExecuteStoreQuery <userinfo>(sql).ToList(); //List<userinfo> uselist2 = entit.ExecuteStoreQuery<userinfo>(sql2).ToList(); if (uselist.Count >= 1) { HttpContext.Current.Session["user"] = userName.ToString(); return(true); } else { HttpContext.Current.Session["user"] = null; return(false); } } catch (Exception e) { //return false; throw; } }