无法访问我本地托管网站的管理信息中心

时间:2017-06-12 19:46:17

标签: php mysql sql

我从某人那里购买了一个代码并在本地托管,但它的工作非常精彩,但我的问题是。我在phpmyadmin中打开了admin表,并获得了管理员电子邮件和加密密码。但由于我不知道密码是什么,我尝试通过phpmyadmin添加另一个管理员帐户(仍使用本地主机),但我仍然无法登录管理仪表板。 任何解决方案?

<?php   require("../includes/config.php");

        require_once(ROOT_PATH . "core/class.admin.php");
    $login = new ADMIN();
    if($login->
is_loggedin() != ""){
        $login->
redirect(BASE_URL.'administrator');
    }
    if(isset($_POST['loginBtn'])){
        $username = strip_tags($_POST['userID']);
        $password = strip_tags($_POST['password']);
                if($login->
doLogin($username, $password)){
            $login->
redirect(BASE_URL.'administrator');
        }
else{
            $error = "Email Address or Password does not match, please try again!";
        }
        }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
Naija Helper</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="http://creativeweb.com.ng" />
<!-- css -->
<link href="<?php echo BASE_URL;
?>
css/bootstrap.min.css" rel="stylesheet" />
<link href="<?php echo BASE_URL;
?>
css/fancybox/jquery.fancybox.css" rel="stylesheet">
<link href="<?php echo BASE_URL;
?>
css/jcarousel.css" rel="stylesheet" />
<link href="<?php echo BASE_URL;
?>
css/flexslider.css" rel="stylesheet" />
<link href="<?php echo BASE_URL;
?>
js/owl-carousel/owl.carousel.css" rel="stylesheet">
<link href="<?php echo BASE_URL;
?>
css/style.css" rel="stylesheet" />
<style type="text/css">
    .formWrapper {
        width: 40%;
        margin: auto;
    }
    @media (max-width: 767px) {
        .formWrapper {
            width: 70%;
            margin: auto;
        }
    }
    @media (max-width: 480px) {
        .formWrapper {
            width: 90%;
            margin: auto;
        }
    }
</style>
</head>
<div class="featured_content" style="margin: 0px;
">
    <div class="formWrapper">
        <div align="center" style="margin-bottom: 20px;
">
            <a style="padding-bottom: 20px;
" href="<?php echo BASE_URL;
?>
">
            <img src="<?php echo BASE_URL;
?>
img/logo.png" alt="logo"/>
</a>
        </div>
        <div align="center" style="margin-bottom: 10px;
">
            <span style="font-size: 28px;
">
Adminstrators only</span>
<br>
            <span>
Secure admin access</span>
        </div>
        <div style="background: #FFF;
 padding: 50px 20px 20px;
 border-radius: 5px;
">
            <?php               if(isset($error))               {
                    ?>
                    <div class="alert alert-danger">
                       <i class="fa fa-exclamation-triangle">
</i>
 &nbsp;
 <?php echo $error;
 ?>
 !                  </div>
                    <?php               }
            ?>
            <form id="contact-form" method="post" action="" role="form" novalidate>
                <div class="form-group has-feedback">
                    <label for="email">
Email Address*</label>
                    <input type="text" class="form-control" id="userID" name="userID" required                  placeholder="Enter your Email Or Username">
                    <i class="fa fa-envelope form-control-feedback">
</i>
                </div>
                <div class="form-group has-feedback">
                    <label for="password">
Password*</label>
                    <input type="password" class="form-control" id="password" name="password" required placeholder="Password">
                    <i class="fa fa-lock form-control-feedback">
</i>
                </div>
                <br>
                <input type="submit" style="width: 100%;
 padding: 20px;
border-radius: 5px;
"               value="Login" name="loginBtn" class="btn btn-default">
            </form>
        </div>
        <div class="row">
            <div class="col-md-6">
                <span style="font-size: 12px;
 padding-left: 10px;
">
                <a style="color: #666;
" href="register">
<i class="fa fa-lock">
</i>
 Register</a>
</span>
            </div>
            <div class="col-md-6" align="right">
                <span style="font-size: 12px;
 padding-right: 10px;
">
                <a style="color: #666;
" href="#">
<i class="fa fa-lock">
</i>
 Forgot Password</a>
</span>
            </div>
        </div>
            </div>
</div>
<?php include(ROOT_PATH."includes/footer.php");
 ?>

2 个答案:

答案 0 :(得分:1)

以下是名为create_hash.php的php页面的代码。它包含一个用于创建新密码哈希的函数createHash()和一个使用它的示例。

要遵循的步骤:

  • 将文件create_hash.php放在项目的某个位置。 但要注意:创建新密码后从项目中删除文件!您可以保存它 - 以供以后使用 - 如果您愿意,可以在文件系统的其他位置保存,不能这样运行;
  • 阅读文件中的注释,它们很重要;
  • 在下面的示例中填写您自己的密码;
  • 根据需要更改createHash()参数;
  • 让文件运行。屏幕上将显示新的密码哈希值;
  • 将新创建的哈希放在admin表中;
  • 尝试再次登录管理信息中心;
  • 从您的项目中删除create_hash.php文件

create_hash.php:

<?php

/**
 * Create a password hash.<br/>
 * 
 * The two digit cost parameter is the base-2 logarithm of the iteration count for<br/>
 * the underlying Blowfish-based hashing algorithmeter and must be in range 04-31.
 * 
 * @param string $password Password to be hashed.
 * @param integer $algo [optional] PASSWORD_DEFAULT|PASSWORD_BCRYPT. Used algorithm.
 * @param integer $cost [optional] Default: 10. Base-2 logarithm of the iteration count. Range 04-31.
 * return string Hashed password (min. 60 characters long).
 */
function createHash($password, $algo = PASSWORD_BCRYPT, $cost = PASSWORD_BCRYPT_DEFAULT_COST) {
    try {
        if ($algo != PASSWORD_BCRYPT || $algo != PASSWORD_DEFAULT) {
            throw new Exception('Incorrect hashing algorithm!');
        }

        if ($cost < 4 || $cost > 31) {
            throw new Exception(' The hashing cost must be in range 04-31!');
        }
    } catch (Exception $exc) {
        echo $exc->getMessage();
        exit();
    }

    $options = array(
        'cost' => $cost,
    );

    return password_hash($password, $algo, $options);
}

//----------------------------------------------------
// Example of using the hashing function createHash().
// Give a password with at least 8 characters,
// including ciphers, letters - lowercase and 
// uppercase, alpha characters (#, $, @, etc).
//----------------------------------------------------
$password = "Lorem#20Ipsum17";
$hash = createHash($password, PASSWORD_BCRYPT, 12);
echo $hash;
//----------------------------------------------------

答案 1 :(得分:0)

你没有在表单元素的action属性中写任何东西。在某个页面上提交表单,并检查用户使用数据库输入的凭据。