私はアプリを開発中です。ログインシステムに問題があります。ユーザーが正しくログインしている場合は、ユーザーを(http://localhost/Media/Index.php#Home)にリダイレクトします。しかし、それは現在のように動作していないようです。私がログイン情報を入力すると、ただリロードされ、何も起こりません。助けてください!Php#ホームページはリダイレクトされません
<?php include ("inc/scripts/mysql_connect.inc.php"); ?>
<?php
session_start(); //Start session
//Check if user is logged in or not
if (isset($_SESSION['user_login'])) {
$user = $_SESSION["user_login"];
}
else {
$user = ""; //Do nothing
//echo"Sorry but your are not logged in!!!!!!!!!!!!!!";
}
?>
<?php
//Login Script
//user Login code
//Check user info when user inputs login information
if (isset($_POST['user_login']) && isset($_POST['password_login']))
{
//filters input info
$user_login = preg_replace('#[^A-Za-z0-9)]#i','', $_POST['user_login']);//filters everything but numbers and letters
$password_login = preg_replace('#[^A-Za-z0-9)]#i','', $_POST['password_login']);//filters everything but numbers and letters
$password_login_md5 = md5($password_login); // encrypt password input because password in database is already encrypted in md5
//use Binary for case sensitive option
$sql = mysqli_query($con, "SELECT * FROM users WHERE BINARY username= BINARY'$user_login' AND password='$password_login_md5' AND closed='no' LIMIT 1"); //query
//check for existence if user exists
$userCount = mysqli_num_rows($sql); //Count the number of rows returned
//if username exists start session
if($userCount==1)
{
while($row = mysqli_fetch_array($sql)) //fecthing the row to display information
{
$id = $row["id"]; // store user id into variable called $id
}
$_SESSION["id"] = $id;
$_SESSION['user_login'] = $user_login;
$_SESSION["password_login"] = $password_login;
header("Location: Index.php#Home");//WE WANT USER TO ACCESS THE #HOME PAGE IF THEY ONLY LOGGED IN SUCCESSFULLY
//exit("<meta http-equiv=\"refresh\" content=\"0\">");
}
else{
//echo"That information is incorrect, Please try again!";
}
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>App</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="themes/myThemeEdited.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<!-- The welcome page where users must provide login info in order to be logged in -->
<div data-role="page" id="Welcome">
<div data-role="header" data-theme="c">
<h1>Welcome</h1>
</div>
<div role="main" class="ui-content">
<form action = "Index.php" method = "POST"><!--provide username and password then submit -->
<input name="user_login" size= "25" placeholder="Username" type="text"/><!-- Enter username/placeholder username-->
<input data-clear-btn="false" name="password_login" size= "25" placeholder="Password" autocomplete="off" type="password"/><!-- Enter password /password placeholder-->
<input name="login" value="Login" type="submit" data-theme="c"/><!-- submit button style it later -->
</form>
<div>
<a href="#Home" data-role="button">Sign Up</a><!--Redirect user to sign up page if user not member yet-->
</div>
</div>
<div data-role="footer" data-position="fixed" data-theme="c"><!-- Footer display/ displays once-->
<h4>(C) 2016</h4><!-- copyright symbols include later-->
</div>
</div><!-- End of the login page-->
<!-- HOME PAGE AND USER PROFILE PAGE where users can enter and submit texts-->
<div data-role="page" id="Home">
<div data-role="header" data-theme="c"><!-- Jquery settings ref included in the header file-->
<h1>Text</h1>
</div>
<div role="main" class="ui-content">
Enter your text<br>
<!-- Allow users to type and send texts-->
<input name="text-basic" id="text-basic" value="" type="text"/><!-- Enter and send text -->
<a href="" data-role= "button" data-theme="c" onClick="submittext(Q)">Send</a><!-- submit button with onclcick function -->
</div>
</div><!-- End of the Home page-->
</body>
</html><!-- End code-->
ログインがちょうどあなたを取るために起こっているので、あなたのログインフォームのアクションプロパティは、ないに '#Home'、index.php''に設定されている:あなたのページの一番下にこのコードを入れて
送信ボタンをクリックするとページに戻ります。 –
Media/Index.phpではなくヘッダ( "Location:Index.php#Home")のみが表示されます。#Home –
@SgtAJですが、http://localhost/Media/Index.php#Homeと入力するとブラウザ私の#Homeページが表示されます。これは、ユーザーがログインしている場合にのみユーザーを招待したい場所です。どうすれば修正できますか? –