asp+mysql__ different types of user logins

Source: Internet
Author: User

/**
* Here code Application scenario for multi-class user login, according to the user choose a different radio button to determine the type of user login,
* In order to make different data tables to determine whether the user name and password is correct.
*/
1  Public Partial class_default:system.web.ui.page2 {   3      Public stringUSER ="", PASSWORD ="";//Filter the user's input4      Public intTYPE =-1;//Verify User-selected type, initial value -15     protected voidPage_Load (Objectsender, EventArgs e)6     {7         if(!IsPostBack)8         {9Username. Text ="";TenPassword. Text =""; One         } A     } -     protected voidButton1_Click (Objectsender, EventArgs e)//determine the user's chosen identity and make the appropriate call function -     { the         Switch(XZ. SelectedValue) -         { -              Case "1": Login (1); Break; -              Case "2": Login (2); Break; +              Case "3": Login (3); Break; -         } +     } A     protected voidButton2_Click (Objectsender, EventArgs e)//jump to the appropriate registration page based on the user's chosen identity at     { -         Switch(XZ. SelectedValue) -         { -              Case "1": Server.Transfer ("zhuce.aspx"); Break; -              Case "2": Server.Transfer ("teachaerzhuce.aspx"); Break; -              Case "3": Response.Write ("<script>alert (' admin registration not open! ');</script>"); Break; in         } -          to     } +     protected voidLoginintTYPE)//user-selected types, performing different actions -     { the         stringType =""; *         Switch(TYPE) $         {Panax Notoginseng              Case 1: Type ="classmate"; Break; -              Case 2: Type ="Teacher"; Break; the              Case 3: Type ="Adminsitrator"; Break; +         } AUSER =username. Text; thePASSWORD =password. Text; +         if(YZ (TYPE, USER, PASSWORD))//Call the YZ () function to determine -         { $             if(Type! ="Adminsitrator") $Response.Write ("<script>alert (' Welcome"+ Type +"go home! '); </script>"); -session["ID"] =USER. ToString (); -session["BZ"] ="Yes";//logo the             Switch(TYPE) -             {Wuyi                  Case 1: Server.Transfer ("students.aspx"); Break; the                  Case 2: Server.Transfer ("teacher.aspx"); Break; -                  Case 3: Response.Write ("<script>alert (' Sorry,administrator's home! ');</script>"); Break; Wu             } -         } About         Else $         { -Response.Write ("<script>alert (' sorry,username or Password error! '); </script>"); -  -         } A  +     } the     protected BOOLYzintTYPE,stringUSER,stringPASSWORD)//Verify the database according to the selected user identity, Success true, fail false -     { $         stringType =""; the         Switch(TYPE) the         { the              Case 1: Type ="stu_"; Break; the              Case 2: Type ="Tea_"; Break; -              Case 3: Type ="Admin_"; Break; in         } the         stringSqlstr ="SELECT * from"+ Type +"where"+ Type +"user= '"+ USER +"' and"+ Type +"pass= '"+ DB. Md5encrypt (PASSWORD) +"';"; theDB db =NewDB ();//The DB class is used to manipulate the database About       //mysqlconnection con = db.conntent (); theMysqldatareader selectcom =db. Select1 (SQLSTR); the          while(selectcom. Read ()) the         { +             return true; -         } the         return false;Bayi     } the}

asp+mysql__ different types of user logins

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.