Newbie Tom asks questions about the session. what I want to achieve is to prevent users from logging on repeatedly. I don't understand the advanced method. I will only use what I can understand. thank you!
First login page
If (! $ Username) {$ aa = 'account does not exist';} else if ($ password! = $ Bb) {$ aa = 'incorrect password ';} else if (! Empty ($ _ SESSION ["username"]) {$ aa = 'logged on to this account ';} else {session_start (); $ _ SESSION ["md5"] = md5 ($ time); $ _ SESSION ["username"] = $ account; DB: query ("UPDATE ". DB: table ('ABC '). "set a = '$ time', B =' {_ _ SESSION [" username "]} ', md5 = '{$ _ SESSION ['md5']}' where name = '$ account' "); $ aa = 'logged in successfully ';}
In this case, the question seems to be caused by the use of $ _ SESSION ["username"] without session_start?
If you delete} else if (! Empty ($ _ SESSION ["username"]); yes, but there are other problems.
The following is the page after logon.
Session_start (); $ md5 =$ _ SESSION ["md5"]; $ username =$ _ SESSION ["username"]; $ aa = DB :: get_one ("SELECT * FROM ". DB: table ('ABC '). "WHERE B = '$ username' and md5 =' $ md5'"); if (! $ Aa) {session_destroy (); echo "script" alert ('you are offline '); script "; echo"