rajp
rajp

Reputation: 1

saving content from textarea in php

i have a textarea in a php page and and i want to save it on click of save button. but i have the insert queries in another php page. how shall i save the content without page refresh. my immediate thought was ajax. but is it safe to transfer content through javascript or should i use session variables to carry the whole text content help me in it.

Upvotes: 0

Views: 548

Answers (3)

Simon
Simon

Reputation: 3539

Session variables are only stored on the server, so they cannot be used to transfer data from the client to the server. I you want to submit data without having the user to reload the page, ajax is the way to go.

Upvotes: 0

Haim Evgi
Haim Evgi

Reputation: 125604

i think the ajax is the best solution,

make in your server side (php) sanity before insert to db (like mysql_real_escape_string)

Upvotes: 1

Dan Grossman
Dan Grossman

Reputation: 52372

You can use AJAX. Make sure you use a POST request as the text may be too long to be sent by GET (that is, appended to the URL in a query string).

Sessions are not a valid option. Sessions are files that exist on the server. In order to put the contents of a textarea into a session, you first have to get it to the server, so it's not a solution to the problem of getting the text to the server.

Upvotes: 1

Related Questions