Sending PHP GET data to server using Html links

前端 未结 2 1045
失恋的感觉
失恋的感觉 2021-01-27 07:51

I haven\'t wrote PHP GET requests in a while. So I\'m a little rusty. But how do I send GET data using an Html link. If I use jQuery\'s get method\'s I know how to do it, but I

相关标签:
2条回答
  • 2021-01-27 08:19

    The simple ways is,

    <a href="page.php?string1=str&string2=str&string3=str"></a>
    

    or a form doing,

    <form action="page.php" method="get"></form>
    
    0 讨论(0)
  • 2021-01-27 08:26

    Put the parameters behind the url:

    index.php?param1=yes&param2=no
    

    Then you can read the variables over $_GET

    echo $_GET['param1'];
    

    But this are PHP basics. Perhaps you should read the documentation before.

    In jQuery with an ajax request its the same. You can put your parameters behind the url.

    $.get('index.php?param1=yes&param2=no', function(data) {
      $('.result').html(data);
      alert('Load was performed.');
    });
    

    If you want to read all GET Parameters you can use a foreach loop.

    foreach($_GET as $key => $value) {
        echo $key.":".$value;
    }
    
    0 讨论(0)
提交回复
热议问题