pick up link from which a file has been called .PHP

0

I am using a php file (which in essence is HTML, but with variables), where I have variables such as $url , which contains the link to another .PHP file. The question is that in this link I also have information that I want to extract in the php that it calls.

To open the second php, I do it this way:

<a href='<?php echo $url ?>' class="oval"> ACEPTAR </a>

Is there any way to collect the variable $url in another php? (sending it when calling said php, for example).

Looking for this topic I found the function ob_get_contents(); but I'm not sure how to apply it for this case Would this function be valid?

    
asked by user91042 20.06.2018 в 10:18
source

1 answer

1

Problem

If I understand correctly, what you want to do is:

  • A link on the php page, let's call it paginaa.php , to another paginab.php . Sending information from one to another.

Ways to send information between PHP pages.

The way to send information between pages is three:

The First, through $ _POST and $ _GET

In the páginaa.php we have:

<a href='<?php echo $url ?>' class="oval"> ACEPTAR </a>

<a href='http://mipagina.com/paginab.php&a=0?b=2' class="oval"> ACEPTAR </a>

Therefore, it can be obtained by the global variable that has php that is $ _GET.

More information: Here

The second, using $ _SESSION

This is another way, if in that case you have the user logged in. For the $ _SESSION, with which if you do:

$_SESSION["dato"] = "este dato";

On the other page you can get it without problem. Whenever you start with <?php session_start() .. , your page.

More info: here .

The third, through Cookies.

We set the time of the cookie and recover it with $_COOKIE .                    

<?php
if(!isset($_COOKIE[$cookie_name])) {
    echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
    echo "Cookie '" . $cookie_name . "' is set!<br>";
    echo "Value is: " . $_COOKIE[$cookie_name];
}
?>

</body>
</html>

Source: Here .

    
answered by 20.06.2018 / 11:15
source