#native_company# #native_desc#

PHP-Based Chat Room Page 3

By Mike Hall
on July 30, 2000

Now we finally have all we need to write the new file :


// Opens file for writing and truncates file length to zero.

$open_file fopen("messages.html""w");

// write file header...


// ... new line...

// (stripSlashes because we don't want all

// our escape characters appearing in the

// message file)


// ... old lines ...


// ... and footer.


// Close the file when you're done. Don't forget to wash your hands



So we now have a very very basic web chat. Let’s look
at some of the features.
<form action="chat.php3">
Name : <input type="text" name="name"> Color: <input type="text" name="color"><br>
Message : <input type="text" name="message"><br>
<input type="submit" name="Send">
We’ve added a new input to the form, meaning we get
a nice new variable to play with in the script. We
read the old messages as before, but in compiling
the new one, we use a little more HTML.


$new_message "<font color="$color">$name : $message</font><br>n";


And while we’re thinking about it, we’ll add a
few more bells and whistles.


$time date("H:i");

$new_message "<font color="$color"><b><i>$name</i></b>".

" <font size="1">($time)</font> : $message</font><br>n";