我正在使用Bootstrap v3,如果用户登录,我在菜单中加载了一个jQuery下拉列表。所有标准的jquery和css文件都没有编辑任何文件。
下拉列表会在除changepassword.php页面之外的所有页面上加载。我不明白为什么。
我该如何开始调试呢?在将来,如果我遇到类似的问题,我首先需要知道问题是什么,这样我的问题就不会那么模糊。对此感到抱歉。
我有萤火虫,我该怎么办才能看到导致这个问题的原因?
这是代码:header.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="favicon.png">
<?php
require_once 'core/init.php';
$user = new User();
$path = $_SERVER['PHP_SELF'];
$page = basename($path);
$title;
switch("$page")
{
case 'index.php':
$title = 'Homepage';
break;
case 'register.php':
$title = 'Register';
break;
case 'login.php':
$title = 'Login';
break;
case 'profile.php':
$title = 'Profile';
break;
case 'changepassword.php':
$title = 'Change Your Password';
break;
case 'update.php':
$title = 'Update Your Profile';
break;
}
echo '<title>'.$title.'</title>';
?>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="assets/css/offcanvas.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Maghnatis</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav">
<?php if(!$user->isLoggedIn()) { ?>
<li class=""><a href="login.php">Login</a></li>
<li class=""><a href="register.php">Register</a></li>
<?php } else { ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo escape($user->data()->username); ?> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="profile.php?user=<?php echo escape($user->data()->username); ?>">Profile</a></li>
<li class="divider"></li>
<li><a href="update.php">Edit Profile</a></li>
<li><a href="changepassword.php">Change Password</a></li>
<li class="divider"></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</li>
<?php } ?>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
这是changepassword.php
<?php
require_once 'core/init.php';
$user = new User();
if(!$user->isLoggedIn()) {
Redirect::to('index.php');
}
include('includes/header.php');
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'password_current' => array(
'required' => true,
'min' => 6
),
'password_new' => array(
'required' => true,
'min' => 6
),
'password_new_again' => array(
'required' => true,
'min' => 6,
'matches' => 'password_new'
),
));
if($validation->passed()) {
if($validation->passed()) {
if(Hash::make(Input::get('password_current'), $user->data()->salt) !== $user->data()->password) {
echo 'Your current password is wrong.';
} else {
$salt = Hash::salt(32);
$user->update(array(
'password' => Hash::make(Input::get('password_new'), $salt),
'salt' => $salt
));
Session::flash('home', 'Your password has been changed.');
Redirect::to('index.php');
}
}
} else {
foreach($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
}
?>
<div class="container">
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-xs-12 col-sm-9">
<p class="pull-right visible-xs">
<button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas">Toggle nav</button>
</p>
<div class="jumbotron">
<h1>Change Your Password</h1>
<p>
<form action="" method="post">
<div class="form-group">
<label for="password_current">Current Password</label>
<input type="password" class="form-control" name="password_current" id="password_current">
</div>
<div class="form-group">
<label for="password_new">New Password</label>
<input type="password" class="form-control" name="password_new" id="password_new">
</div>
<div class="form-group">
<label for="password_new_again">New Password Again</label>
<input type="password" class="form-control" name="password_new_again" id="password_new_again">
</div>
<button type="submit" class="btn btn-default">Change</button>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
</form>
</p>
</div>
<div class="row">
</div><!--/row-->
</div><!--/span-->
<?php include 'includes/sidebar.php'; ?>
</div><!--/row-->
<hr>