0

Hey, this is my first post here, so greetings lol. Back to the topic, Is it possible to make a text box that can put the text into html code and if so how? Sort of like the box you type your post's with on forums or blogs.

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by diafol
0

This is normally done using MySQL or MongoDB to save the data and PHP to display it.
You can use flat files but then you loose a lot of the power you can get from databases like MySQL or MongoDB
A simple, flat-file example would be

<?php
//Output whatever is stored in the file
@echo file_get_contents('./storage');
?>
<!--Make a form for input-->
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<input type="text" name="input" /><input type="submit" />
</form>

<?php
//If the form has been submitted
if ( isset($_POST) ) {
    //Open the file for writing (w)
    $f = fopen('./storage', 'w');
    //Write the string
    fwrite($f,$_POST['input']);
    //Close the file
    fclose($f);
}
?>

(Not tested)
That code is very insecure and using files is very inefficient as opposed to databases.
If you check out http://tizag.com/ they have good tutorials on both PHP files and MySQL with PHP.
-Sam

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.