-3

目前,我的网站是一个使用 scripteen facebook 封面脚本制作的 facebook 封面网站。如果我登录到管理面板并且 login.php 控制登录到管理面板,则允许我的管理面板访问:

<?
session_start();
ob_start();
?>
<?php include('../db.php');?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Scripteen FB Covers Script - Admin Control Panel</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<div class="headcontaint">
<div class="logo"><a href="index.html"><img src="../images/logo.png" width="280" height="74"></a></div>

</div>
</header>
<div class="container">
<div class="maintitle">Login to Admin Contol Panel</div>
<?php
$err=isset($_GET['error'])?$_GET['error']:""; 
if($err=='error'){?>
<div class="errormsgbox">Wrong Username or Password. Please try again.</div>    
<?php }

if(!isset($_SESSION['adminuser'])){
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$adminuser=mysql_real_escape_string($_POST['adminuser']); 
$adminpassword=mysql_real_escape_string($_POST['adminpassword']); 
$gpassword=md5($adminpassword); // Encrypted Password
$sql="SELECT id FROM admin WHERE adminuser='$adminuser' and adminpassword='$gpassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

// If result matched $username and $password, table row must be 1 row
if($count==1)
{
session_register("adminuser");

header("location:index.php");
}
else
{
header("location:login.php?error=error");

}
}
ob_end_flush();

?>
<div class="box">
<div class="login_box">
<form action="login.php" method="post">
<div class="login_input">
<label class="loginlbl"  for="adminuser">UserName :</label>
<input type="text" name="adminuser"/>
</div>
<div class="login_input">
<label class="loginlbl"  for="adminpassword">Password :</label>
<input type="password" name="adminpassword"/>
</div>
<div class="login_submit">
<input type="submit" id="submit" value=" Login to Admin Contol Panel"/>
</div>
</form>
</div>

</div>
<?php }else{
header("location:index.php");
}

include('footer.php');
?>

但是,在 PHP 5.4.0 中不推荐使用 session_register 和 session_is_registered。我怎样才能让这个代码工作,以便它可以与 5.4.0 一起工作?

我真的不知道要对其进行哪些修改才能工作,请帮我解决这个问题。

4

2 回答 2

1

Php.net 声明如下:

// Use of session_register() is deprecated
$barney = "A big purple dinosaur.";
session_register("barney");

// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION["zim"] = "An invader from another planet.";
于 2013-08-05T17:19:27.640 回答
0

在第42行 *更改*

session_register("adminuser");

$_SESSION['adminuser'] = $adminuser;

谢谢

于 2013-11-20T18:23:25.567 回答