I wrote it myself in the afternoon and used it for the company's products. I wrote the stored procedure for the first time. Send the code. If you have any questions, ask me.
Delimiter $ </P> <p> drop procedure if exists 'tsts _ user '. 'proc _ login' $ </P> <p> Create definer = 'root' @ 'localhost' procedure 'proc _ login' (ID varchar (50 ), PWD varchar (255), ptypeuser int, serverip varchar (20), IP varchar (50), out result INT) <br/> begin </P> <p> # return record <br/> # declare ploginid varchar (50); <br/> set @ ploginid = NULL; <br/> set @ ppwd = NULL; <br/> set @ pusertype = NULL; <br/> set @ pendtime = NULL; <Br/> set result = NULL; </P> <p> select @ ploginid: = 'loginid', @ ppwd: = 'Password', @ pusertype: = ptype, @ pendtime: = endtime, name, groupname, area, notlogin, validdate, <br/> viewnews, viewgp, viewqh, viewwp, viewwh, viewgg, userlevel, memo, viewgp_max, viewqh_max, viewwp_max, <br/> viewwh_max, viewgg_max, usercfg, begintime, usedtotaltime, <br/> isonline, serverip from product P where loginid = ID; </P> <p> # If the account does not exist <br/> If (@ plogini D is null) Then <br/> set result = 1; <br/> else <br/> # If the account exists, but the password is incorrect <br/> If (@ ppwd is null or @ ppwd! = PWD) Then <br/> set result = 2; <br/> else <br/> # If the account exists and the password is correct, but it expired <br/> If (@ pendtime is null or now ()> @ pendtime) Then <br/> set result = 3; <br/> else <br/> # If the account exists, the password is correct, and the account has not expired, however, the logon type is incorrect. <br/> If (@ pusertype is null or ptypeuser not in (0, 16, 18, @ pusertype) Then <br/> set result = 4; <br/> else <br/> # update the product set last_access_time = now (), login_times = login_times + 1, isonline = 1, serverip = serverip, last_access_ip = IP where loginid = ID; <br/> end if; </P> <p> # If result is null, it is changed to 0 <br/> If (result is null) Then <br/> set result = 0; <br/> end if; </P> <p> end $ </P> <p> delimiter;