私は最近、学生がさまざまなトピックに関連するファイルをアップロードできるポータルにログインできるサイトを作成しました。
最近、学生から、私のサイトは Google Chrome で動作しないとの連絡がありました。彼が受け取るエラーは、「このサイトにはリダイレクト ループがあります」です。
ここの誰かが見て、Google Chrome の観点から私が間違っていることを確認できますか?
PS サイトは、他のすべてのブラウザでうまく機能します。
<?php
session_start();
function loggedin()
{
if (isset($SESSION['myusername']) || isset($_COOKIE['myusername']))
{
$loggedin = TRUE;
return $loggedin;
}
}
if (loggedin())
{
header("Location: login_success.php");
}
if(isset($_POST['submit']))
{
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="password"; // Mysql password
$db_name="data_base_name"; // Database name
$tbl_name="users"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$rememberme=$_POST['rememberme'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$encrypted_mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);
mysql_close();
// Mysql_num_row is counting table row
if(mysql_num_rows($result) == 1) //user exists
{
if ($rememberme=="on"){
setcookie("myusername", $myusername, time()+7200);
}
elseif ($rememberme==""){
$_SESSION['myusername'] = $myusername;
}
header('Location: login_success.php');
exit();
}
else {
echo '<div class="alert">Incorrect Username or Password!</div>';
}
}
?>
<?php
// DETECT MOBILE DEVICE
//session_start();
$user_agent=$_SERVER['HTTP_USER_AGENT'];
$iphone = strpos($user_agent,"iPhone");
$android = strpos($user_agent,"Android");
$palmpre = strpos($user_agent,"webOS");
$berry = strpos($user_agent,"BlackBerry");
$ipod = strpos($user_agent,"iPod");
if($_GET['mobile_site'])
{
if (strcmp($_GET['mobile_site'],"false")==0)
$_SESSION['mobile_site']=false;
if (strcmp($_GET['mobile_site'],"true")==0)
$_SESSION['mobile_site']=true;
}
if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
$_SESSION['mobile_device']=true; //
if (isset($_SESSION['mobile_site']))
{
}
else
$_SESSION['mobile_site']=true;
}
else
{
$_SESSION['mobile_site']=false;
$_SESSION['mobile_device']=false;
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Secure Customer Login</title>
<meta charset="UTF-8" />
<script type="application/javascript" src="scripts/bubble_bookmark.js" charset="utf-8"></script>
<link rel="apple-touch-icon" href="/images/apple-touch-icon.png">
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<?php if($_SESSION['mobile_site']==true){ ?>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<?php } ?>
<script type='text/javascript'>
function navigator_Go(url) {
window.location.assign(url);
}
</script>
<script type="text/javascript">
var addToHomeConfig = {
touchIcon: true,
};
</script>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/structure.css">
<script>document.createElement('footer');</script>
</head>
<body>
<center><img src="/images/logo.png"></center>
<form class="box login" name="login" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
<fieldset class="boxBody">
<label>Username</label>
<input type="email" name="username" tabindex="1" placeholder="Email" required="required">
<label><?php if($_SESSION['mobile_site']==true){ ?><a href="javascript:navigator_Go('recovery.php');" class="rLink" tabindex="5">Forget your password?</a><?php } ?><?php if($_SESSION['mobile_site']==false){ ?><a href="recovery.php" class="rLink" tabindex="5">Forget your password?</a><?php } ?>Password</label>
<input type="password" name="password" tabindex="2" placeholder="Password" required="required">
</fieldset>
<footer>
<label><input type="checkbox" tabindex="3" name="rememberme">Keep me logged in</label>
<input type="submit" name="submit" value="Login" class="btnLogin" tabindex="4">
</footer>
</form>
<footer id="main">
© 2011 Fixnode Computer Services. All rights reserved.</a>
</footer>
</body>
</html>