HTML - Transmission of a "variable" in PHP

December 2016




Issue


With HTML and PHP, I want to retrieve (in a page) the value of a field of a record in a table. Then, at the click of a button (in a form on this page) this value should be sent to another page (the form's action).

But I do not know how to pass this value
I tried with the transmission URL variable but believe that I put as a string, so it's useless.


For example, if I put in the URL mysite/page.php?variable1=$ variable_to_transmit I think he sent the string "$ variable_to_transmit" and not the content of the variable$ variable_to_transmit. "I already know that this is normal since I use a variable declared in the PHP's internal URL that is in html but I do not know another way.

Solution


If you use a form, you will have a more elegant solution:


And you're recovered in the following page with $ _POST ['variable1']
This solution has the advantage of not burdening your URL and makes the variable "invisible" user.

Note


Thanks to swoog42 for this tip.

Related :

This document entitled « HTML - Transmission of a "variable" in PHP » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.