Skip to content
Advertisement

Getting value of clicked element in PHP

I have a page with element <a> acting like a <button>, in this form the elements works like a service plans, and i want to get a value when one of these buttons has been clicked.

Page1.php

JavaScript

Page2.php

JavaScript

I know that $_POST['name'] doesn’t works cuz don’t exist a input, but i don’t know how use something like this to get a value of button clicked and show this value.

The return expected for first button for example, is something like:

JavaScript

I need this value to put in database after.

Someone can help me to get this values?

Advertisement

Answer

You may pass the value as a url parameter

JavaScript

And get it from $_GET in your php code

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement