Q:

Making a text input just strings and no code

I Have a problem.
I am making a live chat out of php (I am new to php), and it takes your name, $theName, and theMessage, and it writes it to a txt file and then reads the txt file and displays it on index.php. My problem is that in the message box, you could write something like <b style="color: green;">Hello</b> and it would make that message green. How do you make it so that the user can't put code in the input, and instead just a plain string?
Here is a segment of my php:
$handle = fopen("view.txt", "a");
fwrite($handle, $theName . " - " . $theMessage . "\n"); //this is where you can put code that I don't want
fclose($handle);
$theName = NULL;
$theMessage = NULL;
echo $emptyLink;  //the index.php

A:

You have wysiwyg plug-ins that make it right (e.g : TinyMCE).
Include it in you chat system and it will make it for you.
But if you insists, htmlspecialchars() will allow you to have a string that is not readable as HTML but as string. Then you can play with it in the processing.

