session_start();
function loginForm(){
echo'
';
}
if(isset($_POST['enter'])){
if($_POST['name'] != ""){
$_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name']));
}
else{
echo 'Please type in a name';
}
}
?>
if(isset($_GET['logout'])){
//Simple exit message
$fp = fopen("log.html", 'a');
fwrite($fp, "User ". $_SESSION['name'] ." has left the chat session.
");
fclose($fp);
session_destroy();
header("Location: index.php"); //Redirect the user
}