tags:

views:

288

answers:

4

How do you output text from a textbox directly into an html page where it will be stored permanently?

The purpose of the question is that I would like to implement a comment script for a site like this: ommmm.de/modelle_sticky.htm Each time a team memeber hits one of the buttons "Comments - send" I would like that everything that was typed into the textbox below will update immediately into the space above. (I was thinking php-mysql before, but I'd also like to know the most simple way of using the very same html file the comments are on as the flat file storage).

EDIT: It just seems odd to me that there seems to be not one most simple solution where you can type something into a textbox, hit a button and have it be embedded as html on the same page right away.

Thanks for the article on how to insert data into a database table. But then, what will be the best way of retrieving the data? Do a Select * on each column in each table everytime the page reloads? Is that it?

+2  A: 

You will need to save the data onto the server storing the webpage. Either by:

  • Writing it into the HTML file itself or
  • Storing it in a database

I think this is a pretty large question to answer fully here, so i think we need more info from you.

EDIT:

Again this is a pretty large subject, what I suggest is to create a database table to hold the comments and then have a PHP form (or whatever language you are comfortable with) that submits the info into the database.

The you have another script that read from the database to display the current comments.

I don't want to just paste some PHP Comment tool or Guest book tool because I have no idea how well it is done and how easy it is for you to implement. I also don't know your programming level.

So I am going to point you to this W3Schools article on inserting data into a database. BE AWARE though that this example is not secure to use live on the web.

Ólafur Waage
ok I added some more info to my question
Sebas
A: 

You need to use some service side logic + AJAX to do it. In general let say you pick PHP as your server side script language, you will need to write some script which will be able to receive text parameter and store it on the disk and then make and AJAX call there you will pass text from textbox (using POST) to that script.

EDIT: JavaScript for security reason doesn't allowed to make any disk access (except cookies) especially on server. I just cannot understand why you are so negative about proposed solution. In a words it does sound very easy task, but behind there is some job to be done. So each time you reload the page you will be needed to re-select the data from DB table and create an HTML one, exactly as you will need to re-read the data from HTML file existing on the server, which were updated. You want to improve it? Implement caching. There is a simple ways(let say using jquery) just to insert the new entered text, inside the already existing DOM structure, but it wouldn't be persistent at any place after you will have to reload the page. So don't try to find the easiest way, there it's not possible.

Artem Barger
that sounds complicated
Sebas
do you have other ideas? You do need to somehow persist the data on the server. The only option is to pass that data to server and say to server to store it. will be very useful if you will share you thoughts and which server side language you are thinking to use, so I be able to generate an example for, so you will see how simple it's.
Artem Barger
+1  A: 

if I am not wrong you can use javascript to reconstruct your comment portion and same time make a call to your webservice through javascript you can easily find tutorials for that. Hope that works...

Pranali Desai
A: 

I am using Multiline text box in my projetc for Comments purpuse But this one is not Shown paragraphs dfhdsfgfgfgfgfgfgsd dsjkfgsdjkgfsdjkgj

Vara