0

i have a webpage form which have different no of textbox.
i have to send this data to a sql database
but i dont want to use the $_post or $_get command
infact i don't want to send my data to other php page
so i basically want a php equivalent of javascript getelementbyid() function so that i can get the values of extboxes when the user clicks a button.

any one pls help...thanx in advance

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

The only way for PHP to get form data is to use GET or POST. In PHP you can use PHP DOM* to get an element by id, but it will retrieve the page and analyze it, this page will not contain the data inserted in the form, because is not a value already present but is related only to the client session. In other words your textarea will be empty.

If you have different textarea tags then use different names:

<textarea name="t1"></textarea>
<textarea name="t2"></textarea>
<textarea name="t3"></textarea>
<textarea name="t4"></textarea>

* http://www.php.net/manual/en/domdocument.getelementbyid.php

Edited by cereal: n/a

0

If you are good at JS and want to send only what is needed not the whole form there is a solution. You can write a little JS function to get only what you want and send it via AJAX when button is clicked.
But again you need to look at $_POST or $_GET or even $_COOKIE at backend. PHP treats your data as ARRAY of elements. Unlike JS, PHP requires that you issue a request to the server so PHP is triggered and can do something with your data, and return a response for you.

0

I think you've misunderstood the functionality of client and server-side code. If you don't SEND, you don't get on the server without Ajax (as mentioned by fenixz).
Ajax will send data to php via POST or GET anyway.

Ajax is the way to go if you don't want a whole page refresh/reload (call it what you want) when you want to send form data.

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.