Do not want the log deleted

[php]

<?php session_start(); function loginForm(){ echo'

Please enter your name to continue:

Name:
'; } if(isset($_POST['enter'])){ if($_POST['name'] != ""){ $_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name'])); //Clear file //$fp = fopen("log.html", 'w'); //fclose($fp); $fp = fopen("log.html", 'a'); fwrite($fp, "
User ". $_SESSION['name'] ." has entered the chat session.
"); fclose($fp); } else{ echo 'Please type in a name'; } } ?> KappaChat <?php if(!isset($_SESSION['name'])){ loginForm(); } else{ if(isset($_GET['logout'])){ //Clear file //$fp = fopen("log.html", 'w'); //fclose($fp); //Simple exit message $fp = fopen("log.html", 'a'); fwrite($fp, "
User ". $_SESSION['name'] ." has left the chat session.
"); fclose($fp); session_destroy(); echo ''; //Show login form again } ?>

Have a cucumber, <?php echo $_SESSION['name']; ?>

Exit Chat

<?php if(file_exists("log.html") && filesize("log.html") > 0){ $handle = fopen("log.html", "r"); $contents = fread($handle, filesize("log.html")); fclose($handle);
	echo $contents;
}
?></div>

<form name="message" method="post">
	<input name="usermsg" type="text" id="usermsg" size="63" />
	<input name="submitmsg" type="submit"  id="submitmsg" value="Send" />
</form>
<?php } ?> [/php]

[php]

<?php session_start(); if(isset($_SESSION['name'])){ $text = $_POST['text']; //Clear file $fp = fopen("log.html", 'w'); fclose($fp); $fp = fopen("log.html", 'a'); fwrite($fp, "
(".date("g:i A").") ".$_SESSION['name'].": ".stripslashes(htmlspecialchars($text))."
"); fclose($fp); } ?>[/php]

Here is my index and my post for a simple chat application. It deletes the log.html everytime I reload the page, and I don’t want that. How do I fix it? I dont’ necessarily want it all showing, but don’t want it deleted. I am VERY new so noob friendly talk with me please, and show me changes you’d make.

why are you clearing it then? you dont need that first open/close. just append it.

Sponsor our Newsletter | Privacy Policy | Terms of Service