Sending Data via Link (POST or GET)

2

Good morning my dear ones, I'm new here ...

First of all, I want to point out that I already read the topics that exist in this forum and I could not solve my problem!

My problem is to send only the id of the bank from one PHP page to another that will do the select through that id and show all the data of the bank related to the sent id. I want to do this through a link, and I'm not getting it.

<h2>
    <font size="5">
        <a href="mostrar.php" target="_blanck">
            <?=$linha['titulo']?>
        </a>
    </font>
</h2>

The idea is to send the id through this line of code there.

    
asked by anonymous 18.02.2017 / 12:44

1 answer

2

Via POST you will have to make a form.

Via GET just send the id at the end of the url.

<a href="mostrar.php?id=<?=$linha['id']?>" target="_blank"><?=$linha['titulo']?></a>

The url looks like this:

mostrar.php?id=5

In the mostrar.php file you use this way:

$id = $_GET['id'];

But it's interesting before you check to see if $_GET['id'] actually exists:

if (isset($_GET['id'])) {
  $id = $_GET['id'];
}
    
18.02.2017 / 13:20