我正在尝试创建一个带有会话的管理页面。我从 admin.php 收到以下两个错误。
Deprecated: Function session_is_registered() is deprecated in /home/content/95/10216895/html/test/admin.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at /home/content/95/10216895/html/test/admin.php:4) in /home/content/95/10216895/html/test/admin.php on line 7
代码如下所示:
<?php
//Start the session
session_start();
//Get the user name from the previously registered super global variable
define(ADMIN, $_SESSION['name']);
if (!session_is_registered("admin"))
{
//If session not registered, redirect to login.php page
header("location:login.php");
}
else
{
header( 'Content-Type: text/html; charset=utf-8' );
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
另一个文件 check_login.php 中用于设置变量的登录检查代码如下:
$sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass=SHA1('$mypassword')";
//echo '<p>'.$sql.'</p>';
$result=mysqli_query($dbC, $sql);
//echo '<p>'.$result.'</p>';
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if ($count==1)
{
// Register $myusername, $mypassword and redirect to file "admin.php"
session_start();
$_SESSION['name'] = 'admin';
$_SESSION['password'] = 'password';
// session_register("admin");
// session_register("password");
// $_myusername= $myusername;
$_SESSION['name']= $myusername;
header("location:admin.php");
}
谁能帮我解决这个问题?