PHP 4.3.3

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

    PHP 4.3.3

    Ok I hope someone can clear this up for me because my laptop is going
    in the bin or across the room soon.

    I have installed versions:

    MySQL 4.0.15
    Apache 2.0.47
    PHP 4.3.3

    I have put the php4ts.dll in c:\winnt\system 32\
    I have changed the php.ini in c:\winnt\
    I have changed the httpd.conf in c:\Program FIles\Apache
    Group\Apache2\c onf\

    I have done bloody everything...

    Apache I know works I can get the page up when I go localhost on
    browser.
    MySQL works because I have tried examples.
    PHP seems to work with most things, but not with IF () statements!

    for example:

    <?php
    if ($submit == "Go") {
    echo("you wrote ".$you_wrot e);
    echo("<br>You could have written");
    exit;
    }
    ?>
    <form action="<?php echo($PHP_SELF) ?>" method="POST" >
    <p>Input a word <input type="text" size="20" name="you_wrote ">
    <input type="submit" name="Submit" value="Go"></p>
    </form>

    If I save this as php file and go to browser and call it up, I get
    notice come up

    "Notice: Undefined variable: submit in C:\Program Files\Apache
    Group\Apache2\h tdocs\test0.php on line 2"

    Line being if ($submit == "Go") {

    Can someone please tell me what needs doing please....
  • Bert

    #2
    Re: PHP 4.3.3

    On 30 Sep 2003 07:32:18 -0700, w.bristow@rchl. org.uk (Wayne) wrote:
    [color=blue]
    >Ok I hope someone can clear this up for me because my laptop is going
    >in the bin or across the room soon.
    >
    >I have installed versions:
    >
    >MySQL 4.0.15
    >Apache 2.0.47
    >PHP 4.3.3
    >
    >I have put the php4ts.dll in c:\winnt\system 32\
    >I have changed the php.ini in c:\winnt\
    >I have changed the httpd.conf in c:\Program FIles\Apache
    >Group\Apache2\ conf\
    >
    >I have done bloody everything...
    >
    >Apache I know works I can get the page up when I go localhost on
    >browser.
    >MySQL works because I have tried examples.
    >PHP seems to work with most things, but not with IF () statements!
    >
    >for example:
    >
    ><?php
    >if ($submit == "Go") {
    > echo("you wrote ".$you_wrot e);
    > echo("<br>You could have written");
    > exit;
    >}
    >?>
    ><form action="<?php echo($PHP_SELF) ?>" method="POST" >
    ><p>Input a word <input type="text" size="20" name="you_wrote ">
    ><input type="submit" name="Submit" value="Go"></p>
    ></form>
    >
    >If I save this as php file and go to browser and call it up, I get
    >notice come up
    >
    >"Notice: Undefined variable: submit in C:\Program Files\Apache
    >Group\Apache2\ htdocs\test0.ph p on line 2"
    >
    >Line being if ($submit == "Go") {
    >
    >Can someone please tell me what needs doing please....[/color]


    Not sure, but did you try if ($_POST['submit'] == "Go") {...
    B.

    Comment

    • Bert

      #3
      Re: PHP 4.3.3

      On Tue, 30 Sep 2003 14:40:12 GMT, Bert <bert@pandora.i nvalid> wrote:


      [color=blue]
      >
      >Not sure, but did you try if ($_POST['submit'] == "Go") {...
      >B.[/color]

      and change $PHP_SELF to $_SERVER['PHP_SELF'] while you're at it :)
      B.

      Comment

      • Justin Koivisto

        #4
        Re: PHP 4.3.3

        Bert wrote:
        [color=blue]
        > On Tue, 30 Sep 2003 14:40:12 GMT, Bert <bert@pandora.i nvalid> wrote:
        >
        >
        >
        >[color=green]
        >>Not sure, but did you try if ($_POST['submit'] == "Go") {...
        >>B.[/color]
        >
        >
        > and change $PHP_SELF to $_SERVER['PHP_SELF'] while you're at it :)
        > B.
        >[/color]

        Or if you don't want to edit tons of files, in php.ini:
        register_global s = On

        --
        Justin Koivisto - spam@koivi.com
        PHP POSTERS: Please use comp.lang.php for PHP related questions,
        alt.php* groups are not recommended.

        Comment

        • Phil Roberts

          #5
          Re: PHP 4.3.3

          With total disregard for any kind of safety measures
          w.bristow@rchl. org.uk (Wayne) leapt forth and uttered:
          [color=blue]
          > Ok I hope someone can clear this up for me because my laptop is
          > going in the bin or across the room soon.
          >
          > I have installed versions:
          >
          > MySQL 4.0.15
          > Apache 2.0.47
          > PHP 4.3.3
          >
          > I have put the php4ts.dll in c:\winnt\system 32\
          > I have changed the php.ini in c:\winnt\
          > I have changed the httpd.conf in c:\Program FIles\Apache
          > Group\Apache2\c onf\
          >
          > I have done bloody everything...
          >
          > Apache I know works I can get the page up when I go localhost on
          > browser.
          > MySQL works because I have tried examples.
          > PHP seems to work with most things, but not with IF ()
          > statements!
          >
          > for example:
          >
          > <?php
          > if ($submit == "Go") {
          > echo("you wrote ".$you_wrot e);
          > echo("<br>You could have written");
          > exit;
          > }
          > ?>
          > <form action="<?php echo($PHP_SELF) ?>" method="POST" >
          > <p>Input a word <input type="text" size="20" name="you_wrote ">
          > <input type="submit" name="Submit" value="Go"></p>
          > </form>
          >
          > If I save this as php file and go to browser and call it up, I
          > get notice come up
          >
          > "Notice: Undefined variable: submit in C:\Program Files\Apache
          > Group\Apache2\h tdocs\test0.php on line 2"
          >
          > Line being if ($submit == "Go") {
          >
          > Can someone please tell me what needs doing please....[/color]

          You need to set the error reporting to suppress notices, it
          explains how in php.ini

          --
          There is no signature.....

          Comment

          • Andy Hassall

            #6
            Re: PHP 4.3.3

            On Tue, 30 Sep 2003 12:14:55 -0500, Phil Roberts <philrob@HOLYfl atnetSHIT.net>
            wrote:
            [color=blue]
            >You need to set the error reporting to suppress notices, it
            >explains how in php.ini[/color]

            You could also close your eyes, that works too. Don't ignore warnings; they're
            there for a reason!

            In this case the OP seems to think that global variables will be defined for
            form inputs; they aren't, unless you change the configuration, and there's good
            reasons why you shouldn't.

            Look up 'register_globa ls', the Predefined Variables section of the manual,
            and the 4.1.0 and 4.2.0 release announcements on php.net.

            --
            Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
            Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

            Comment

            • medi

              #7
              Re: PHP 4.3.3


              "Wayne" <w.bristow@rchl .org.uk> wrote in message
              news:b4c26164.0 309300632.48fec e3c@posting.goo gle.com...[color=blue]
              > Ok I hope someone can clear this up for me because my laptop is going
              > in the bin or across the room soon.
              >
              > I have installed versions:
              >
              > MySQL 4.0.15
              > Apache 2.0.47
              > PHP 4.3.3
              >
              > I have put the php4ts.dll in c:\winnt\system 32\
              > I have changed the php.ini in c:\winnt\
              > I have changed the httpd.conf in c:\Program FIles\Apache
              > Group\Apache2\c onf\
              >
              > I have done bloody everything...
              >
              > Apache I know works I can get the page up when I go localhost on
              > browser.
              > MySQL works because I have tried examples.
              > PHP seems to work with most things, but not with IF () statements!
              >
              > for example:
              >
              > <?php
              > if ($submit == "Go") {
              > echo("you wrote ".$you_wrot e);
              > echo("<br>You could have written");
              > exit;
              > }
              > ?>
              > <form action="<?php echo($PHP_SELF) ?>" method="POST" >
              > <p>Input a word <input type="text" size="20" name="you_wrote ">
              > <input type="submit" name="Submit" value="Go"></p>
              > </form>
              >
              > If I save this as php file and go to browser and call it up, I get
              > notice come up
              >
              > "Notice: Undefined variable: submit in C:\Program Files\Apache
              > Group\Apache2\h tdocs\test0.php on line 2"
              >
              > Line being if ($submit == "Go") {[/color]

              That's because submit buttons never pass their name as variable (POST or
              GET).
              That's why hidden fields are used. Try this:

              <?php

              if (isset($_POST['status']))
              {
              if($_POST['status'] == "Go")
              {
              echo("you wrote ".$_POST['you_wrote']);
              echo("<br>You could have written");
              exit;
              }
              }

              ?>

              <form action="<?php echo($_SERVER['PHP_SELF']) ?>" method="POST">< p>
              Input a word <input type="text" size="20" name="you_wrote ">
              <input type="submit" name="submit" value="Go">
              <input name="status" type="hidden" value="Go">
              </form>

              Hope this will help....


              Comment

              • Andy Hassall

                #8
                Re: PHP 4.3.3

                On Tue, 30 Sep 2003 23:36:30 +0200, "medi" <medi@spinter.n et> wrote:
                [color=blue][color=green]
                >> <input type="submit" name="Submit" value="Go"></p>
                >> </form>
                >>
                >> If I save this as php file and go to browser and call it up, I get
                >> notice come up
                >>
                >> "Notice: Undefined variable: submit in C:\Program Files\Apache
                >> Group\Apache2\h tdocs\test0.php on line 2"
                >>
                >> Line being if ($submit == "Go") {[/color]
                >
                >That's because submit buttons never pass their name as variable (POST or
                >GET).
                >That's why hidden fields are used. Try this:[/color]

                Named submit controls can be successful controls:

                <form method="get" action="">
                <input type="submit" name="submitBut ton" value="whatever ">
                </form>
                <pre>
                <?php
                var_dump($_GET) ;
                ?>
                </pre>

                Submit the form back to itself, output is:

                array(1) {
                ["submitButt on"]=>
                string(8) "whatever"
                }



                "If a form contains more than one submit button, only the activated submit
                button is successful. "

                Therefore a submit button can be successful, and so sends a value.

                --
                Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
                Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

                Comment

                Working...