SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    getting repeated id in url

    hi all

    i want to fetch "ord" from

    Code:
    http://localhost/repair_mobile_form/?ord=403
    in php i have code

    PHP Code:
    <?
    $order_id
    =$_REQUEST['ord'];
    if(isset(
    $_REQUEST['submit']))
    {
    echo 
    "<script language='javascript'>";
    echo 
    "var url = window.location.href.toString()";
    echo 
    "\n";
    echo 
    "var id = url.match(/\?ord=(\d+)/)";
    echo 
    "\n";
    echo 
    "window.location='http://localhost/repair_mobile_review/' + id";
    echo 
    "</script>";
    }
    ?>
    but this code redirects the url to

    Code:
    http://localhost/repair_mobile_review/?ord=403,403
    why am i getting two repeating id's in url

    vineet

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use id[1] instead of id in the penultimate line, to get just the part matched by the parenthesised expression. The variable id is an array.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Use id[1] instead of id in the penultimate line, to get just the part matched by the parenthesised expression. The variable id is an array.
    thanks Autistic

    it worked as needed

    vineet


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •