A section of PHP login code
Now there is a section of PHP code, I want to set the login password to the specified number, not from the database to take, let me see how to change?
/**
**============================================================================
* ============================================================================
*/
$dir _name=str_replace (' \ \ ', '/', dirname (__file__));
$admindir =substr ($dir _name,strrpos ($dir _name, '/') +1);
Define (' Cms_path ', Str_replace ($admindir, ', $dir _name));
Define (' Inc_path ', Cms_path. ' includes/');
Define (' Data_path ', Cms_path. ' data/');
Include (Inc_path. ' fun.php ');
Include (Data_path. ' confing.php ');
Include (Inc_path. ' mysql.class.php ');
if (file_exists (data_path. ' sys_info.php ')) {
Include (Data_path. ' sys_info.php ');
}
$mysql =new MySQL (db_host,db_user,db_password,db_name,db_charset,db_pconnect);
Session_Start ();
$_session[' login_in ']=empty ($_session[' login_in '])? ": $_session[' login_in '];
$_session[' admin ']=empty ($_session[' admin ')? ': $_session[' admin '];
if ($_session[' login_in ']&&$_session[' admin ') {header ("location:admin.php");}
$action =empty ($_get[' action ')? ' Login ': $_get[' action '];
$password =empty ($_post[' password ')? ": $_post[' password '];
$user =empty ($_post["user"])? ": $_post[' password '];
$code =empty ($_post[' code ')? ": $_post[' Code '];
$submit =empty ($_post[' submit ')? ': $_post[' submit '];
Go_url ($action);
function Login () {
Global $_sys;
Include (' template/admin_login.html ');
}
function Ck_login () {
Global $submit, $user, $password, $_sys, $code;
$submit =$_post[' Submit '];
$user =fl_html (Fl_value ($_post[' user '));
$password =fl_html (fl_value ($_post[' password '));
$code =$_post[' code ';
if (!isset ($submit)) {
MSG (' Please enter ' from the landing page ');
}
if (Empty ($user) | | Empty ($password)) {
MSG ("Password or user name cannot be null");
}
if (!empty ($_sys[' Safe_open ')) {
foreach ($_sys[' Safe_open ') as $k = = $v) {
if ($v = = ' 3 ') {
if ($code!=$_session[' code ') {msg ("The CAPTCHA is incorrect! ");}
}
}
}
Check_login ($user, $password);
}
function out () {
Login_out ();
}
?>
------Solution--------------------
Then you will have your Check_login ($user, $password);
The $password variable of the method is set directly to a number. In the method, the number you pass is compared to your method.
------Solution--------------------
Fun.php the code to post this file
------Solution--------------------
PHP Code
Check_login ($user, $password) {($password = = ' 12345 ')? $_session[' login_in '] = Yes:die ("error");}
------Solution--------------------
There are a few notes to take a look at yourself because I don't know if your other code is useful to those variable handling.
PHP Code
function Check_login ($user, $password) {/* $rel = $GLOBALS [' MySQL ']->fetch_asc ("select Id,admin_name,admin_passwor D,admin_purview,is_disable from ". Db_pre. " admin where Admin_name= ' ". $user." ' Limit 0,1 '); $rel =empty ($rel)? ': $rel [0]; if (empty ($rel)) {msg (' does not exist for the administrative user ', ' login.php '); } $password =md5 ($password); if ($rel [' is_disable ']) {msg (' The account has been locked and cannot be logged in '); } */$oldPassword = ' 12345 '; Default fixed password if ($password! = $oldPassword) {msg ("Incorrect password entered"); } if (!isset ($_session)) {session_start (); } $_session[' admin '] = $rel [' Admin_name ']; $_session[' admin_purview '] = $rel [' Admin_purview ']; Here you need the code according to the car to process//$_session[' admin_id ' = $rel [' id ']; Here the ID needs to be processed according to the program code $_session[' Admin_time ' = time (); $_session[' login_in '] = 1; $_session[' login_time '] = Mktime (); $ip = Fl_value (Get_ip ()); $ip = fl_html ($IP); $_session[' admin_ip '] = $ip; Unset ($rel); Header ("location:admin.php");}