javascript - PhP login redirect stops working after applying CSS and JS to the code -
i trying write simple login code. problem code works , redirects dashboard.php without css , js files. include header file,consisting of css , js, stops working , gets stuck on auth_check.php. here code.
main index file ( index.php) - containing login form
<?php include('header.php');?> <?php $message = $_get['message']; if($message == 1) { echo ' <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert"> invalid username or password.</br> ×</button> </div> '; } if($message == 2) { echo ' <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert"> have logged out! </br> ×</button> </div> '; } ?> <div data-role="content"> <div id="loginform" > //login form code <form action="auth_check.php" method="post"> // form action="auth_check.php" <div id="usernamediv" data-role="field-contain"> <input type="text" id="name" name="username" placeholder="username"> </div> <div id="passworddiv" data-role="field-contain"> <input type="password" id="password" name="password" placeholder="password"> </div> <div id="loginbuttondiv" data-role="field-contain"> <button type="submit" name="submit" id="loginbutton"></button> </div> </form> </div> <?php include('footer.php'); ?>
authorisation check (auth_check.php) (here header(location:) doesnt work after applying js in index.php :(
<?php include('config.php'); session_start(); include 'passwordhash.php'; $hasher = new passwordhash(8, false); if (!empty($_post)) { $username = $sql->real_escape_string($_post['username']); $query = "select id, password, unix_timestamp(created) salt users username = '{$username}'"; $user = $sql->query($query)->fetch_object(); if ($user && $user->password == $hasher->checkpassword($_post['password'], $user->password)) { session_register("username"); // session checker pages $_session['username']= $username; // storing username in session header("location: dashboard.php"); exit; } else { header("location: index.php?message=1"); exit; } } ?>
here file header.php causing problem.
<?php include('config.php'); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <link rel="stylesheet" type="text/css" href="custom.css"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile- 1.4.2.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script> <script type="text/javascript" src="js/login.js"></script> <head>
Comments
Post a Comment