<?php
session_start();
if(!isset($_SESSION['account'])){
if(isset($_POST['account']))
{
$db=new mysqli('localhost','webuser','111111','users');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} $stmt=$db->prepare("SELECT account FROM logins WHERE
account=? and password=?");
$account = $_POST['account'];
$password = $_POST['password'];
//**************************************************
$res = $stmt->bind_param('ss', $account, $password);
//**************************************************
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows==1)
{
$stmt->bind_result($account);
$stmt->fetch();
$_SESSION['account']=$account;
header("Location:index.htm");
} else {
require_once('login.htm');
echo "<p>Here isn't such user or wrong password!</p>";
}
}else{
require_once('login.htm');
}
}else{
echo "You have already logged into the site";
}
?>
session_start();
if(!isset($_SESSION['account'])){
if(isset($_POST['account']))
{
$db=new mysqli('localhost','webuser','111111','users');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} $stmt=$db->prepare("SELECT account FROM logins WHERE
account=? and password=?");
$account = $_POST['account'];
$password = $_POST['password'];
//**************************************************
$res = $stmt->bind_param('ss', $account, $password);
//**************************************************
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows==1)
{
$stmt->bind_result($account);
$stmt->fetch();
$_SESSION['account']=$account;
header("Location:index.htm");
} else {
require_once('login.htm');
echo "<p>Here isn't such user or wrong password!</p>";
}
}else{
require_once('login.htm');
}
}else{
echo "You have already logged into the site";
}
?>
在 $stmt->fetch(); 后面echo $account; exit;看看
有报错信息吗?
看一下报错日志...