-3

I am coming up with a way to display user profiles. Right now I am able to insert the user_id into the url when going to a user's profile, but I am unsure of how to get the user_id from the url.

So at the end of the url I have this:

profile?user=41

I just want to be able to get the 41 (please note this number will change per profile) and then set it to a variable.

How would I do this?

Paul
  • 3,348
  • 5
  • 32
  • 76

2 Answers2

1
<?php
    echo $_GET['user'];
?>

all the parameters of the url are stored in the $_GET variable...

FalcoB
  • 1,333
  • 10
  • 25
0
The parameter that are in your URL can be retrieved with the

predefined variable:

<?php
    //$userId = $_GET["pramName"];
    $userId = $_GET["user"];
    // or 
    // using the $_REQUEST variable   
?>
Yves Kipondo
  • 5,289
  • 1
  • 18
  • 31