| 发表于:2007-03-01 17:43:307楼 得分:30 |
原始方法 try { string ss;//set a string ss use for the md5 input password ss=system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(userpassword.value, "md5 "); oracleconnection myconnection=new oracleconnection(configurationsettings.appsettings[ "oracleconnstring "]); myconnection.open(); try { oracledataadapter mycommand = new oracledataadapter( "select * from log_stu where stunum= ' "+userid.value+ " ' ", myconnection); dataset ds = new dataset(); mycommand.fill(ds, "log_stu "); //judge the login user is or not the system user if (ds.tables[ "log_stu "].rows.count==0) { errormessage.text = "找不到此用户[ "+userid.value+ "], 请重新输入 "; return; } if (ss!=ds.tables[ "log_stu "].rows[0][ "pwd "].tostring()) { errormessage.text = "密码错误[ "+userpassword.value+ "], 请重新输入 "; return; } //query the database and put the user id into the session session[ "user_name "]=userid.value; //login success then goto page stu_default.htm response.redirect( "stu_default.htm "); } finally { myconnection.close(); } } catch(exception e) { errormessage.text=e.message; } } | | |
|