ログインが成功した場合、コードはHTML要素で特定のものをエコーすることになっています
ただし、問題はこれです...ログインすると、「そのユーザーは存在しないか、まだアクティブ化されていません。もう一度押してください」というページが表示されます。ブラウザの「戻る」ボタンを押すと、ログインが成功したときに生成されるはずだった HTML 要素が表示されます。
「そのユーザーは存在しないか、まだアクティブ化されていません。もう一度押してください」は、クエリが空であるか、少なくとも 1 でないことが判明した場合にのみ表示されるはずでした。
参照用のコードは次のとおりです。
<?php
include_once("check_login_status.php");
// Initialize any variables that the page might echo
$e = "";
$joindate = "";
$lastsession = "";
// Make sure the _GET email is set, and sanitize it
if(isset($_GET["em"])){
$e = $_GET["em"];
// echo $e;
} else {
header("location: http://www.yoursite.com");
}
// Select the member from the users table
$sql = "SELECT * FROM user WHERE email='$e' AND active='1' LIMIT 1";
$user_query = mysqli_query($db_connect, $sql);
// Now make sure that user exists in the table
$numrows = mysqli_num_rows($user_query);
// echo $numrows;
if( $numrows != 1 ){
echo "That user does not exist or is not yet activated, press back";
exit();
}
// Check to see if the viewer is the account owner
$isOwner = "No";
if($e == $log_email && $user_ok == true){
$isOwner = "Yes";
}
// Fetch the user row from the query above
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$profile_id = $row["id"];
$signup = $row["signup"];
$lastlogin = $row["lastlogin"];
$joindate = strftime("%b %d, %Y", strtotime($signup));
$lastsession = strftime("%b %d, %Y", strtotime($lastlogin));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $u; ?></title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="style.css">
<script src="main.js"></script>
<script src="ajax.js"></script>
</head>
<body>
<div id="pageMiddle">
<h3><?php echo $e; ?></h3>
<p>Is the viewer the page owner, logged in and verified? <b><?php echo $isOwner; ?></b></p>
<p>Join Date: <?php echo $joindate; ?></p>
<p>Last Session: <?php echo $lastsession; ?></p>
</div>
</body>
</html>
私はすでにいくつかのエコーテストを行っていますが、この別のテストでは...
include_once("db_connect.php");
$e = "MY EMAIL";
$sql = "SELECT * FROM user WHERE email='$e' AND active='1' LIMIT 1";
$user_query = mysqli_query($db_connect, $sql);
// Now make sure that user exists in the table
$numrows = mysqli_num_rows($user_query);
echo $numrows;
numrows は '1' をエコーしますが、メイン コードでは numrows は () をエコーします... $_GET["em"] は、echo で確認したときに MY EMAIL と同じであるため、非常に奇妙です。