Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2003
    Location
    Proud She-Geek
    Posts
    1,722

    Passing form variables with PHP?

    For some reason I am having a total mental block and cannot seem to figure out how to pass form variables from one page to the next using PHP. I also am having trouble finding what I'm looking for when I google it as well.


    Hope someone can help!
    <?php echo "Signature here"; ?>

  2. #2
    Join Date
    Dec 2003
    Location
    Miami, FL
    Posts
    3,262
    Wouldn't a simple

    $subject = $_POST['subject'];

    work?

  3. #3
    Join Date
    Jun 2003
    Location
    Proud She-Geek
    Posts
    1,722
    That's what I thought but in the script I'm working on I have those at the top like

    $cpuname = $_POST['uname'];
    $cpurl = $_POST['url'];

    Then referenced in a format like

    PHP Code:
    $result "http://'. $cpurl .'/'. $cpuname .'.html"
    and again in the 2nd form (there's 4 steps total) further down the page, in hidden fields, like so:
    PHP Code:
    <input type=hidden name=uname value=<?php echo $cpuname?>
    But when I view the source of the outputted page the value= is empty
    <?php echo "Signature here"; ?>

  4. #4
    Join Date
    Dec 2003
    Location
    Miami, FL
    Posts
    3,262
    hmm

    try

    <?php echo("$cpuname"); ?>

    or
    <? echo "$cpuname"?>

  5. #5
    You can easily carry them usin a GET method.

  6. #6
    Kuja, what's the point passing them trough GET method when even POST method for some reason isn't working? Changing the method doesn't mean that problem will go away.

    P-nut, try adding print_r($_POST) after issuing POST to see if $_POST was even created and filled.
    There might be some weird case that you got redirected for some reason and thus lost all your posted variables.
    Posting the code bit somewhere might help us track the problem.

  7. #7
    It could perhaps be a case of the "IE enter key" bug.

  8. #8
    Join Date
    Mar 2005
    Location
    India
    Posts
    68
    Originally posted by P-nut
    Then referenced in a format like
    PHP Code:
    $result "http://'. $cpurl .'/'. $cpuname .'.html"
    Your $result is not looking good. You are using a combination of double and single quotes. Can u check that again ?
    Whats wrong in an innocent cup of tea ?
    -----
    Bobcares.com

  9. #9
    Yes, $result isn't good but even though, $cpurl and $cpuname are within double quotes so they sould evaluate.

  10. #10
    Join Date
    Mar 2005
    Location
    India
    Posts
    68
    Thats true maxymizer, but I was just wondering . Why does he need that "single" quotes?

    P-nut , like maxymizer said , print of _POST .. and I would like to see the "FORM" tag too. Lets catch it.
    Whats wrong in an innocent cup of tea ?
    -----
    Bobcares.com

  11. #11
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    iaef, use sessions.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  12. #12
    Usually i use echo to print the form, thus every variable is defined.
    Try use something like this
    <?php
    echo "<form type='whatever' method='whatever'>";
    echo "<input type='text' name='uname' value='" .$cpurl. "'>";
    echo "</form>";
    ?>

  13. #13
    Join Date
    May 2004
    Location
    Milton, Florida
    Posts
    783
    Try Making a Hidden Input form option for the variables from the previous page..

    As for the $result.. That looks perfectly fine.. It turns that line into something like

    http://www.hisdomain.com/control_panel_page.html

    The Double quotes are there to set $result to everything inside it.. Then the single quotes are there for a purpose aswell..

    Just my .02 (BTW; this was my 250th post )

  14. #14
    Originally posted by platinumn23

    As for the $result.. That looks perfectly fine.. It turns that line into something like
    $result will print http://'. www.domain.com .'/'. somepage .'.html
    actually

    That's why it's kinda wrong but that still isn't the reason why POST-ing doesn't work.

Posting Permissions

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