2017-06-12 94 views
0

我从某人处购买了一个代码并将其托管在本地,并且它工作得非常好,但是我的问题是。我在phpmyadmin中打开了管理表,并获得了管理员电子邮件和加密的密码。但是因为我不知道密码是什么,我尝试通过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"); 
?> 
+0

你需要检查PHP –

+0

登录代码向我们展示了登录代码,请。 – 2017-06-12 19:49:48

+0

@aendeerei请检查编辑后的版本我的问题 – Bennyfans

回答

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; 
//---------------------------------------------------- 
0

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

+0

由于我从某人购买了代码并且不擅长php,我该怎么做。没有办法与卖给我的人联系。 – Bennyfans

+0

你诚实地支付这个代码?这非常令人担忧。编写这个代码的人不应该为此付费,而且你也不应该为此付钱。 – markus

+0

Nirav,实际上'action'属性可以是空字符串(“”),或者甚至没有给出。在HTML5中,action属性不再需要。这样,表单就被提交到它所在的同一页面。在@Bennyfans这是工作案例。买的代码也相对不错。它不是MVC,但它包含了让我得出结论的元素(如类,异常处理等),程序员是一位相对有经验的人。确实如此,代码在格式化方面是一团糟:-)在我开始寻找问题之前,我花了很多时间来正确格式化它。 – 2017-06-13 16:15:02

相关问题