Assign value to a variable from URL

Discussion in 'PHP' started by rrn, Apr 23, 2009.

  1. #1
    hi ,

    $graph = "http://www.abc.com/ss";
    PHP:
    is the above shown code correct ?
    i want to take the value from the url and assign it to $graph.
    is it the right way to do it??

    pls give a solution.

    thank you.
     
    rrn, Apr 23, 2009 IP
  2. sandstorm140

    sandstorm140 Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    sure, if you're looking for what I think you are, you can use $_GET.

    For example:
    URL: http://www.abc.com/index.php?m=ss
    or:
    URL: http://www.abc.com/?m=ss

    <?php
    $graph = $_GET['m'];
    //result would be $graph = ss
    ?>

    'm' could be whatever you choose as long as both params on URL and $_GET match
     
    sandstorm140, Apr 23, 2009 IP
  3. beetech

    beetech Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if you wana send values from one page to another via url you can send them like that

    URL : http://www.xyz.com/some_page.php?id=233&name=mike

    now you can catch the values from the url for later use like this


    <?php
    $member_id= $_GET['id'];
    $member_name = $_GET['name'];

    ?>
     
    beetech, Apr 23, 2009 IP