$_POST form variable and use in same php page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brianj

    $_POST form variable and use in same php page

    Apache/2.0.48 (Win32) PHP/4.3.6

    I would like to take a value from a checkbox(checke d or unchecked) and
    then use that value in a php script All on the same page. So I should
    post the form to the same page right?
    And then pick that variable up via $_POST or $_REQUEST methods right?
    I have tried various approaches to the action= clause of the form but
    to no avail. I know how i did it in asp but it doesn't seem to work.
    Any advice?
  • Alvaro G Vicario

    #2
    Re: $_POST form variable and use in same php page

    *** brianj wrote/escribió (3 Jun 2004 22:34:45 -0700):[color=blue]
    > I would like to take a value from a checkbox(checke d or unchecked) and
    > then use that value in a php script All on the same page. So I should
    > post the form to the same page right?
    > And then pick that variable up via $_POST or $_REQUEST methods right?
    > I have tried various approaches to the action= clause of the form but
    > to no avail. I know how i did it in asp but it doesn't seem to work.
    > Any advice?[/color]

    In ACTION you have to type the URL of the page. That's exactly the same in
    PHP, ASP or ColdFusion. What problems have you found?


    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --

    Comment

    • William Holroyd

      #3
      Re: $_POST form variable and use in same php page

      > Apache/2.0.48 (Win32) PHP/4.3.6[color=blue]
      >
      > I would like to take a value from a checkbox(checke d or unchecked) and
      > then use that value in a php script All on the same page. So I should
      > post the form to the same page right?
      > And then pick that variable up via $_POST or $_REQUEST methods right?
      > I have tried various approaches to the action= clause of the form but
      > to no avail. I know how i did it in asp but it doesn't seem to work.
      > Any advice?[/color]

      Use the name of the form element as the key in $_POST to get the value of
      it.

      For example, to access the value of this...

      <input type="checkbox" name="thisISthe NAME" value="whatever you want it to
      be">

      you would need to call this in your PHP script to get it...

      $HTTP_POST_VARS['thisIStheNAME'];

      A good way to see whats being posted is making a file name output.php and
      putting just this in it...

      <?php

      echo '<pre>';
      echo print_r($_POST) ;
      echo '</pre>';

      ?>

      Hope this helps you out.

      -William


      Comment

      Working...