[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');
$fp2 = fopen("longlog.html", 'a+');
fwrite($fp, "<div class='msgln' id=" . time() ."><i>User ". $_SESSION['name'] ." has entered the chat session.</i><br></div>");
fwrite($fp2, "<div class='msgln' id=" . time() ."><i>User ". $_SESSION['name'] ." has entered the chat session.</i><br></div>");
fclose($fp);
fclose($fp2);
}
else{
echo '<span class="error">Please type in a name</span>';
}
}
?>
Have a cucumber, <?php echo $_SESSION['name']; ?>
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
session_start();
if(isset($_SESSION[‘name’])){
$text = $_POST[‘text’];
//Clear file
$fp = fopen("log.html", 'w');
fclose($fp);
$fp = fopen("log.html", 'a');
$fp2 = fopen("longlog.html", 'a+');
fwrite($fp, "<div class='msgln' id=" . time() .">(".date("g:i A").") <b>".$_SESSION['name']."</b>: ".stripslashes(htmlspecialchars($text))."<br></div>");
fwrite($fp2, "<div class='msgln' id=" . time() .">(".date("g:i A").") <b>".$_SESSION['name']."</b>: ".stripslashes(htmlspecialchars($text))."<br></div>");
fclose($fp);
fclose($fp2);
}
?>[/php]
It worked before, just fine. Sadly, I forgot to save a copy of it when it worked. I did not altar the scroll area of the index at all since it worked. Just other areas. Here’s the two big files… index and post…respectively.