Although it is a simple database connection code, it is ultimately used to determine user permissions. If you need it, you can refer to it. Although it is a simple database connection code, it is ultimately used to determine user permissions. If you need it, you can refer to it.
Script ec (2); script
The Code is as follows: |
|
Error_reporting (0 ); Session_start (); // Database tutorial connection $ Conn = mysql tutorial _ connect ('localhost', 'root ',''); Mysql_select_db ('chenkn', $ conn ); Mysql_query ('set NAMES UTF-8 '); // Define a constant Define ('all _ Ps', 'php '); Function user_shell ($ uid, $ shell, $ m_id ){ $ SQL = "select * from admin where uid = '$ uid '"; $ Query = mysql_query ($ SQL ); $ Row = mysql_fetch_array ($ query ); $ Shell = is_array ($ row )? $ Shell = md5 ($ row ['username']. $ row ['Password']. ALL_PS): FALSE; If ($ shell ){ If ($ row ['m _ id'] <= $ m_id ){ Return $ row; } Echo "your permissions are insufficient "; Exit (); } Else { Echo "You are not authorized to access this page "; Exit (); } } Function user_mktime ($ onlinetime ){ $ New_time = mktime (); If ($ new_time-$ onlinetime)> '20140901 '){ Session_destroy (); Echo "Login timeout "; Exit (); } Else { $ _ SESSION ['times '] = mktime (); } } ?> |