点击提交时没有任何反应

时间:2017-01-26 05:50:52

标签: php

请帮我处理我的代码。

当我尝试点击登录时,没有任何反应。我无法确定代码中的问题是什么。

请检查我的代码。

mainlogin.php

<?php
include 'checklogin.php';
if ( isset($_SESSION['username'])!="" ) {
header('location:home.php');
exit();}?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/style.css">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href="css/main_login.css">
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>Local.ph <small>Admin Page</small></h1>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12 col-xs-offset-3"><p>Log in <small>Please Log in your account</small></p></div>
<div class="col-xs-5 col-xs-offset-3 ">
<div class="form-group">    
<form  method="POST" >
<label for="username">Username: </label>
<input type="text" class="form-control" name="username">
<label for="password">Password: </label>
<input type="password" class="form-control" name="password"></br>
<input type="submit" name="submit" class="btn btn-success"  value="Login">
</form>
</div>
</div>
</div>
</div>
</body>
</html>

checklogin.php

<?php
include 'include/connection.php';
session_start();
if (isset($_POST['submit']) ){
$myusername=$_POST['username']; 
$mypassword=$_POST['password']; 
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysqli_real_escape_string($conn, $myusername);
$mypassword = mysqli_real_escape_string($conn, $mypassword);
$sql="SELECT USERNAME FROM admin_accnt WHERE USERNAME='".$myusername."' and PASSWORD='".$mypassword."'";
$result=mysqli_query($conn,$sql);
$count=mysqli_num_rows($result);
if($count == 1){
$row = mysqli_fetch_assoc($count);
$_SESSION['username'] = $row['USERNAME'];
header("location:home.php");
}else {
echo"<script> alert('Check Username and Password.');</script>";
}
}
?>

home.php

<?php
session_start();
include 'include/connection.php';
if (!isset($_SESSION['username'])){
header("location:mainlogin.php");
exit;}
?>
<html>
<body>
<p>test</p>
<h1 class="hello">Hello, <em><?php echo $_SESSION['username'];?>!</em></h1>
</body>
</html>

connection.php

<?php
$host = "localhost";
$connusername = "root";
$connpassword = "";
$dbname = "bearskin";
$conn = mysqli_connect("$host", "$connusername", "$connpassword",          "$dbname"); 
?>

感谢所有提前帮助

0 个答案:

没有答案