-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,238
  • 3
  • 27
  • 64

2 Answers2

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

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

FalcoB
  • 1,303
  • 10
  • 24
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
  • 4,832
  • 1
  • 17
  • 26