わかりました、私のlogin.php
ページでこの解析エラーが発生します。ユーザーがすでにログインしているかどうかを確認するためにコードが考慮されていないようです。ログインしてpagechecker.php
いるかどうかを確認する各ページで呼び出されるファイルがありますが、その表示はすべて各ページの上部にあるphpコードです。
エラーlogin.php
は次のとおりです。
解析エラー: 構文エラー、予期しない '('、予期しない識別子 (T_STRING) または変数 (T_VARIABLE) または '{' または '$' が C:\inetpub\wwwroot\OTLCoding\PHP\login.php の 21 行目にあります
base.php
<?php
session_start();
$dbhost = "localhost";
$dbname = "login";
$dbuser = "root";
$dbpass = "DirectedStudies2012";
$mysqli = new mysqli($dbhost,$dbuser,$dbpass,$dbname);
?>
login.php
<?php
include ("base.php");
include ("passwordchecker.php");
include ("functions.php");
include("pagechecker.php");
function postInput($htmlName)
{
if(isset($_POST[$htmlName]))
{
return $_POST[$htmlName];
}
return null;
}
//check if the user is already login.
if(isset($_SESSION['userid']))
{
//check the database for existing user.
$usercheck->$mysqli->("SELECT * FROM user WHERE userid = ?");
$usercheck->bind_param("i",$_SESSION['userid']);
$usercheck->execute();
$usercheck->store_result();
$results = $usercheck->num_rows;
if($results == 1)
{
redirect("languages.php");
}
}
$loginusername = postInput('username');
$loginpassword = postInput('password');
if(isset($_POST['submit']))
{
if($loginusername == "" || $loginpassword == "")
{
$error = "Please Enter your user name and password";
}
else
{
//user isnt logged in
if($stmt = $mysqli->prepare("SELECT userid, password FROM user WHERE username = ? LIMIT 1"))
{
$stmt->bind_param("s",$loginusername);
$stmt->execute();
$stmt->bind_result($userid,$correctHash);
$stmt->fetch();
if(ValidatePassword($loginpassword,$correctHash))
{
$_SESSION['userid'] = $userid;
redirect('languages.php')
}
$stmt->close();
}
}
}
}
?>
pagechecker.php
//used to check for already login.
if(!isset($_SESSION['userid']))
{
header("Location: login.php");
}
else
{
$usercheck->$mysqli->("SELECT * FROM user WHERE userid = ?")
$usercheck->bind_param("i",$_SESSION['userid']);
$usercheck->execute();
$usercheck->store_result();
$results = $usercheck->num_rows;
if($results == 0)
{
header("Location: login.php");
}
}