-1

I have a really odd problem with $_GET. I'm fairly new to the HTML/CSS/PHP/MySQL stack. I've not used $_GET before and I'm trying to write a page that is used by a link in an email that confirms the user's email. The link contains a single parameter which is a GUID that I cross-reference against a database entry. While developing this, I've had problems getting hold of the $_GET parameters, so I've cut the page down to a test page thus:

<html>
    <head>
    </head>
    <body>
        Hullo.<br/>
        <?php
            echo $_GET['testparam'];
        ?>
        <br/>
        World.
        <br/>
    </body>
</html>

I am then calling this with:

http://mywebsite/dev/test.html?testparam=2

I get the following output:

Hullo.

World.

What is going on? I cannot make the test simpler. I'm using PHP 7.1 if that helps. Any advice very gratefully received.

Mark Roworth
  • 409
  • 2
  • 15

2 Answers2

0

I'm not sure your page is interpretted as PHP by the server until you declare .html files to be interpretted as PHP (in apache or whatever).

Write <-?php echo "2"; ?> in your page to be sure.

REname your page test.php and it should work if it's your problem.

Oulalahakabu
  • 504
  • 3
  • 6
-1

I have run the test on my server setup and get the following response:

Hullo.
2
World.

So it may be a case that PHP isn't configured properly. To test this try something such as setting a variable then printing it.

<?PHP
$x = 2;
echo $x;
?>

if this fails then read the PHP installation docs to make sure you have it installed correctly. http://php.net/manual/en/install.php

EDIT:

Just noticed you are trying to do it off a HTML page. The page needs extension: .php .php5 .php7 and such.

Read here: http://php.net/manual/en/tutorial.php