Home  >  Q&A  >  body text

How to send data to PHP page when link is clicked?

I have multiple links (e.g. 100 - 120) in my HTML page. What I really need is to send different data to another PHP page (e.g. display.php) when I click each link. I tried a pathetic approach,

<form action="display.php" method="post"> // or GET
   <input type="hidden" name ="data" value="Data1" />
   <input type="submit" value="Link 1" />
</form>`  
.  
.  
.  

<form action="display.php" method="post">
   <input type="hidden" name ="data" value="Data120" />
   <input type="submit" value="Link 120" />
</form>

Is there any simple way to reduce the use of these 120 forms?

P粉311464935P粉311464935307 days ago496

reply all(2)I'll reply

  • P粉267791326

    P粉2677913262024-01-10 16:48:25

    Yes of course Try using tag with id

    link1

    Hope this helps

    reply
    0
  • P粉933003350

    P粉9330033502024-01-10 10:44:25

    You can place data directly on the href of the tag.
    For example:

    Click here

    Then in your display.php file:

    for you.

    reply
    0
  • Cancelreply