logout.php

来自「shooting flash game with script」· PHP 代码 · 共 42 行

PHP
42
字号
<?php 
require_once('xmlHandler.php');
$fn_xml = "chatroom.xml";

if (!isset($_COOKIE["name"])) {
	header("Location: error.html");
	exit;
}

$name = $_COOKIE["name"];

// setcookie("valid",0);
$xmlh = new xmlHandler($fn_xml);

if (!$xmlh->fileExist()) {
		header("Location: error.html");
		exit;
	}
	
$xmlh->openFile();
		
$users_node = $xmlh->getElement("users");
	$users_array = $xmlh->getChildNodes("user");
	
	if($users_array != null)
	{
		foreach ($users_array as $users)
		{
			$uname = $xmlh->getAttribute($users, "name");
			
     	   		if ($uname==$name)
				$xmlh->removeElement($users_node,$users);
		}
	}	
		
	
$xmlh->saveFile();
setcookie("name", "");


header("Location: login.html");
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?