nusphere phped: variable post

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mikespam@gmx.de

    nusphere phped: variable post

    Hello,
    I'm using nusphere phped to develop php files. I have written
    to files named a.php and b.php.

    a.php:
    ------
    <html>
    <body>
    please enter two numbers in the form.<br>
    <form action = "b.php" method = "post">
    Wert 1: <input name = "w1"><p>
    Wert 2: <input name = "w2"><p>
    <input type = "submit">
    <input type = "reset">
    </form>
    </body>
    </html>

    b.php:
    ------
    <html>
    <body>
    <?php

    $erg = $w1 + $w2;
    echo "sum: $erg";
    ?>
    </body>
    </html>

    If I enter numbers in the form, the result (erg) is always 0.
    Is it possible that the post method doesnt't work (I have the feeling that
    w1 and w2 are local variables)?
    Do I have to change settings in Nuspere phped?

    Thanks a lot,
    Mike
  • Geoff Berrow

    #2
    Re: nusphere phped: variable post

    I noticed that Message-ID:
    <b2f06300.04071 10302.2df99b7e@ posting.google. com> from mikespam@gmx.de
    contained the following:
    [color=blue]
    >If I enter numbers in the form, the result (erg) is always 0.
    >Is it possible that the post method doesnt't work (I have the feeling that
    >w1 and w2 are local variables)?
    >Do I have to change settings in Nuspere phped?[/color]

    Nope. Do this:

    $erg = $_POST['w1'] + $_POST['w2'];
    echo "sum: $erg";

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Michael Austin

      #3
      Re: nusphere phped: variable post

      Geoff Berrow wrote:
      [color=blue]
      > I noticed that Message-ID:
      > <b2f06300.04071 10302.2df99b7e@ posting.google. com> from mikespam@gmx.de
      > contained the following:
      >
      >[color=green]
      >>If I enter numbers in the form, the result (erg) is always 0.
      >>Is it possible that the post method doesnt't work (I have the feeling that
      >>w1 and w2 are local variables)?
      >>Do I have to change settings in Nuspere phped?[/color]
      >
      >
      > Nope. Do this:
      >
      > $erg = $_POST['w1'] + $_POST['w2'];
      > echo "sum: $erg";
      >[/color]

      In order to make sure I get all of the variables, I use something like
      this at the beginning of my scripts:
      <?php
      if (!empty($_GET))
      {
      extract($_GET);
      }
      else if (!empty($HTTP_G ET_VARS))
      {
      extract($HTTP_G ET_VARS);
      }
      if (!empty($_POST) )
      {
      extract($_POST) ;
      }
      else if (!empty($HTTP_P OST_VARS))
      {
      extract($HTTP_P OST_VARS);
      }

      -- yes it is overkill, but everything works all the time now... :)

      Michael Austin.

      Comment

      Working...