URL parameters

Hi all!

I’m completely new at php so I have no idea what i’m doing.

Say I had a site with a page called content.php

If someone were to visit content.php?user=anthony

I’d like all instances of some sort of variable in the code to change to anthony.

For example:

If a link was set up for , it would display as

Can someone lead me in the right direction?

Hi there,

In your content.php wherever you want the parameter value to be inserted use $_GET[‘parameter’]. I have used your example below:

<p>Your username is <?php echo trim($_GET['user']); ?>.</p>

When visiting content.php?user=anthony, the file would output:
“Your username is anthony.”

Sponsor our Newsletter | Privacy Policy | Terms of Service