Php/js

Discussion in 'PHP' started by lektrikpuke, May 19, 2008.

  1. #1
    Boss decided he wanted my PHP form to be a JS popup. Now my problem is in passing a var (again). I've made a link to launch the popup and the var (category_code) shows in the link, but doesn't appear in the PHP page that's launched by the JS.

    <a href=\"http://some_page.php?category_code=" . $category_code . "\" onclick=\"window.open(this.href, 'popupwindow', 'width=650,height=500,left=50,top=50,scrollbars,resizable'); return false;\">Wrap Link Around This Text</a>";

    Help?
     
    lektrikpuke, May 19, 2008 IP
  2. Ulquiorra

    Ulquiorra Peon

    Messages:
    422
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you fetching the variable in the php using $_GET?

    When you say it "doesn't appear", do you mean the url doesn't have the variable in it?
     
    Ulquiorra, May 19, 2008 IP
  3. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #3
    It's not showing in the url when queried thusly: $loc_url=$_SERVER['SCRIPT_NAME'];
    echo $loc_url; // should show category_code=whatever but only folder and page name show up

    Yes, trying to GET category_code, too: $trim_url=$_GET['category_code'];
     
    lektrikpuke, May 19, 2008 IP
  4. Ulquiorra

    Ulquiorra Peon

    Messages:
    422
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What does echo $_SERVER["PHP_SELF"]; show?
     
    Ulquiorra, May 19, 2008 IP
  5. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #5
    Sorry guys, I had the GET in a conditional statement, which wasn't run till the form was submitted (so the var was gone by then). Sorry to have wasted your time again, but thanks for trying to help.:D
     
    lektrikpuke, May 19, 2008 IP
  6. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #6
    Oh, forgot to mention that I had to use REQUEST to make it work, too. GET wouldn't do it. If anyone has the reason (and would share it with me), I'd love to know. Thanks.
     
    lektrikpuke, May 19, 2008 IP
  7. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #7
    Ok, tested it to see if maybe it was a $_POST var (even though the url is assembled like a $_GET), and it didn't work. Neither $_POST nor $_GET work, but $_REQUEST does. Why? I must have done something wrong, right?
     
    lektrikpuke, May 19, 2008 IP
  8. hotmarket

    hotmarket Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    $_REQUEST include all var (post,get),if you use $_POST,you can't get $_GET var,vice versa
     
    hotmarket, May 20, 2008 IP