连接.php
<?php
$host = "localhost";
$user = "root";
$pass = "mikred###";
$db = "itsupportdb";
$mysqli = new mysqli($host, $user, $pass, $db);
if(mysqli_connect_errno())
{
printf("Connection Failed: %s\n", mysqli_connect_error());
exit();
}
?>
glbLoginFunct.php
<?php
include("connection.php");
class Functions {
public static function __Login()
{
session_start();
if(isset($_POST['btnLogin']))
{
$id = $_POST['user'];
$pass = $_POST['pass'];
$query = $mysqli->prepare("SELECT * FROM syslogin WHERE username=? AND password=? LIMIT 1");
$query->bind_param('ss', $id, $pass);
$query->execute();
$query->bind_result($id, $pass);
$row = $query->fetch();
if($row == true)
{
$_SESSION['LogID'] = 1;
$_SESSION['ProfID'] = 2;
header('Location: test.php');
exit();
}
else
{
?><script type="text/javascript"> alert('ERROR!'); </script><?php
}
}
}
}
?>
mainLogin.php
<?php require("includes/glbLoginFunct.php"); ?>
<form action="<?php $_PHP_SELF ?>" method="POST">
<fieldset>
<legend>LOGIN FORM:</legend>
<label id="user">Username: <input type="text" name="user" maxlenght="10"/></label><br />
<label id="pass">Password: <input type="password" name="pass" maxlenght="7"/></label><br />
<label id="buttons"><input type="submit" class="imgBtn" name="btnLogin" value="Login User"/></label><br />
<a href="index.php?link=Forgot">Forgot Password</a>
</fieldset>
</form>
<?php Functions::__Login() ?>
为什么说:
注意:未定义变量:mysqli in ...\includes\glbLoginFunct.php 第 14 行
致命错误:在第 14 行的 ...\includes\glbLoginFunct.php 中调用非对象的成员函数 prepare()