Search code examples
phphtmlurlgethref

Correct syntax for hyperlink URL with PHP $_GET


I am wondering how I would put information from my website in the URL on the first page of my site, and then on the next page, use $_GET to get the variables from the URL.

I was just wanting to put it in a link like <a href="mywebsite.com/page?name=$name"></a> So would it work if I did it like that, and if it would, how would I get it from the URL?


Solution

  • do

    <a href="http://mywebsite.com/page?name=<?php echo $name; ?>"></a>
    

    And in your page, you could get the name as:

    $name = $_GET['name'];