$_POST value is set but always = null even if you enter something

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • comp.lang.php

    $_POST value is set but always = null even if you enter something

    [PHP]
    Other: <input name="school_ty pe_other" size="30" maxlength="75"
    value="<?php

    if ($_POST['hasReviewedApp licant']) echo $_POST['school_type_ot her'];
    else echo str_replace('"' , '&quot;', str_replace('\\ ', '',
    $result[0]->school_type_ot her));

    ?>">
    [/PHP]

    I verified via both var_dump() and print_r() that
    $_POST['hasReviewedApp licant'] = 1 and that $_POST['school_type_ot her']
    = null, even when you enter something into the text field, it's still
    null!

    Can someone tell me what on earth I did wrong this time? I'm lost here!

    Thanx
    Phil

  • Janwillem Borleffs

    #2
    Re: $_POST value is set but always = null even if you enter something

    comp.lang.php wrote:[color=blue]
    > I verified via both var_dump() and print_r() that
    > $_POST['hasReviewedApp licant'] = 1 and that
    > $_POST['school_type_ot her'] = null, even when you enter something
    > into the text field, it's still null!
    >[/color]

    You need to specify the type of the element (type="text").


    JW


    Comment

    • comp.lang.php

      #3
      Re: $_POST value is set but always = null even if you enter something


      Janwillem Borleffs wrote:[color=blue]
      > comp.lang.php wrote:[color=green]
      > > I verified via both var_dump() and print_r() that
      > > $_POST['hasReviewedApp licant'] = 1 and that
      > > $_POST['school_type_ot her'] = null, even when you enter something
      > > into the text field, it's still null!
      > >[/color]
      >
      > You need to specify the type of the element (type="text").
      >
      >
      > JW[/color]

      I did just that.. school_type_oth er is type="text", which in HTML is
      never a requirement, in fact, before I tried that none of the other
      HTML form element text field tags have type="text" and work just fine.
      I added type="text", still no $_POST['school_type_ot her'] even though I
      entered it!

      Phil

      Comment

      • Janwillem Borleffs

        #4
        Re: $_POST value is set but always = null even if you enter something

        comp.lang.php wrote:[color=blue]
        > I did just that.. school_type_oth er is type="text", which in HTML is
        > never a requirement, in fact, before I tried that none of the other
        > HTML form element text field tags have type="text" and work just fine.
        > I added type="text", still no $_POST['school_type_ot her'] even though
        > I entered it!
        >[/color]

        Can you post the element after the values are parsed in it by PHP?


        JW


        Comment

        • Ken Robinson

          #5
          Re: $_POST value is set but always = null even if you enter something

          comp.lang.php wrote:[color=blue]
          > [PHP]
          > Other: <input name="school_ty pe_other" size="30" maxlength="75"
          > value="<?php
          >
          > if ($_POST['hasReviewedApp licant']) echo $_POST['school_type_ot her'];
          > else echo str_replace('"' , '&quot;', str_replace('\\ ', '',
          > $result[0]->school_type_ot her));[/color]

          Just curious... why are you doing this when

          if ($_POST['hasReviewedApp licant']) echo $_POST['school_type_ot her'];
          else echo
          htmlentities(st ripslashes($res ult[0]->school_type_ot her),ENT_QUOTES );

          Does the same thing,
          [color=blue]
          >
          > ?>">
          > [/PHP]
          >
          > I verified via both var_dump() and print_r() that
          > $_POST['hasReviewedApp licant'] = 1 and that $_POST['school_type_ot her']
          > = null, even when you enter something into the text field, it's still
          > null![/color]

          Please post the code for the whole form.

          Also, when you first enter the processing script, what does:
          <?php echo '<pre>' . print_r($_POST, true) . '</pre>'; ?>
          display on the screen?

          Ken

          Comment

          • comp.lang.php

            #6
            Re: $_POST value is set but always = null even if you enter something


            Ken Robinson wrote:[color=blue]
            > comp.lang.php wrote:[color=green]
            > > [PHP]
            > > Other: <input name="school_ty pe_other" size="30" maxlength="75"
            > > value="<?php
            > >
            > > if ($_POST['hasReviewedApp licant']) echo $_POST['school_type_ot her'];
            > > else echo str_replace('"' , '&quot;', str_replace('\\ ', '',
            > > $result[0]->school_type_ot her));[/color]
            >
            > Just curious... why are you doing this when
            >
            > if ($_POST['hasReviewedApp licant']) echo $_POST['school_type_ot her'];
            > else echo
            > htmlentities(st ripslashes($res ult[0]->school_type_ot her),ENT_QUOTES );
            >
            > Does the same thing,
            >[color=green]
            > >
            > > ?>">
            > > [/PHP]
            > >
            > > I verified via both var_dump() and print_r() that
            > > $_POST['hasReviewedApp licant'] = 1 and that $_POST['school_type_ot her']
            > > = null, even when you enter something into the text field, it's still
            > > null![/color]
            >
            > Please post the code for the whole form.[/color]

            Even if I were allowed to do so - which I'm not as it is fed gov't
            property and even posting code is considered a federal no-no, it's over
            3,000 lines long, sorry :(

            And if it gets weirder I can't duplicate the error, even after several
            tries, $_POST['school_type_ot her'] now exists.

            Phil[color=blue]
            >
            > Also, when you first enter the processing script, what does:
            > <?php echo '<pre>' . print_r($_POST, true) . '</pre>'; ?>
            > display on the screen?
            >
            > Ken[/color]

            Comment

            • Stephen Kay

              #7
              newbie question: can't make newline character work in echo

              learning php here - I'm echoing some debug code, and I cannot seem to make
              the newline character work.

              For example, I tried this:

              echo "supposedly , this will \nbe on \nmultiple lines.";

              which, according to the php manual, should produce this:

              supposedly, this will
              be on
              multiple lines.

              But it doesn't work! It's all on the same line. What obvious thing am I
              missing?

              --
              Stephen Kay
              Karma-Lab sk@karma-lab.NOSPAM.com
              ^^^^^^^


              Comment

              • Stephen Kay

                #8
                newbie question: what is simple way to open a new url from php?

                Sorry for this really basic question, but assuming you have created a URL
                string in your code, how do you cause a window to be opened with that url?

                I've been searching the manual, but haven't found it yet.

                I've seen reference to CURL libraries, but that seems a bit complicated for
                the simple thing I'm trying at the moment. Thanks!


                --
                Stephen Kay
                Karma-Lab sk@karma-lab.NOSPAM.com
                ^^^^^^^


                Comment

                • Jerry Stuckle

                  #9
                  Re: newbie question: can't make newline character work in echo

                  Stephen Kay wrote:[color=blue]
                  > learning php here - I'm echoing some debug code, and I cannot seem to make
                  > the newline character work.
                  >
                  > For example, I tried this:
                  >
                  > echo "supposedly , this will \nbe on \nmultiple lines.";
                  >
                  > which, according to the php manual, should produce this:
                  >
                  > supposedly, this will
                  > be on
                  > multiple lines.
                  >
                  > But it doesn't work! It's all on the same line. What obvious thing am I
                  > missing?
                  >[/color]

                  Display your html source. You'll see the newlines there.

                  This isn't a PHP problem - it's how HTML works. Newline characters are
                  ignored. Instead, you need to use <br> to start a new line.
                  See the nl2br() function.

                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • Stephen Kay

                    #10
                    Re: newbie question: can't make newline character work in echo

                    in article M46dnWlVLO0o0r3 ZnZ2dnUVZ_s-dnZ2d@comcast.c om, Jerry Stuckle at
                    jstucklex@attgl obal.net wrote on 3/21/06 2:08 PM:
                    [color=blue]
                    > This isn't a PHP problem - it's how HTML works. Newline characters are
                    > ignored. Instead, you need to use <br> to start a new line.
                    > See the nl2br() function.[/color]

                    Thanks - I didn't think of looking at the source instead of the screen
                    output. Makes total sense. I've got it doing what I want now.

                    --
                    Stephen Kay
                    Karma-Lab sk@karma-lab.NOSPAM.com
                    ^^^^^^^


                    Comment

                    • Geoff Berrow

                      #11
                      Re: newbie question: what is simple way to open a new url from php?

                      Message-ID: <C045B55F.59520 %sk@karma-lab.nospam.com> from Stephen Kay
                      contained the following:
                      [color=blue]
                      >Sorry for this really basic question, but assuming you have created a URL
                      >string in your code, how do you cause a window to be opened with that url?[/color]

                      That's not php it's html

                      <a href='newpage.p hp' target='_blank' >link to new page (opens in a new
                      window)</a>

                      --
                      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

                      • Stephen Kay

                        #12
                        Re: newbie question: what is simple way to open a new url fromphp?

                        in article 5il022ltt2a8jmv 0jns337ne31mqdc jpae@4ax.com, Geoff Berrow at
                        blthecat@ckdog. co.uk wrote on 3/21/06 2:40 PM:
                        [color=blue]
                        > Message-ID: <C045B55F.59520 %sk@karma-lab.nospam.com> from Stephen Kay
                        > contained the following:
                        >[color=green]
                        >> Sorry for this really basic question, but assuming you have created a URL
                        >> string in your code, how do you cause a window to be opened with that url?[/color]
                        >
                        > That's not php it's html
                        >
                        > <a href='newpage.p hp' target='_blank' >link to new page (opens in a new
                        > window)</a>[/color]

                        That's not what I meant, sorry.

                        Maybe I don't have a clue yet, but I wrote a php function that you call from
                        a button. It takes a bunch of parameters, and assembles them into a URL
                        string.

                        Now that I have the URL string (inside my php function), how do I call that
                        URL and get that page to open up in a window?


                        --
                        Stephen Kay
                        Karma-Lab sk@karma-lab.NOSPAM.com
                        ^^^^^^^


                        Comment

                        • Geoff Berrow

                          #13
                          Re: newbie question: what is simple way to open a new url from php?

                          Message-ID: <C045C39D.598A3 %sk@karma-lab.nospam.com> from Stephen Kay
                          contained the following:
                          [color=blue][color=green]
                          >> <a href='newpage.p hp' target='_blank' >link to new page (opens in a new
                          >> window)</a>[/color]
                          >
                          >That's not what I meant, sorry.
                          >
                          >Maybe I don't have a clue yet, but I wrote a php function that you call from
                          >a button. It takes a bunch of parameters, and assembles them into a URL
                          >string.
                          >
                          >Now that I have the URL string (inside my php function), how do I call that
                          >URL and get that page to open up in a window?[/color]

                          I /think/ you'd probably have to use PHP to output some Javascript to do
                          that.

                          --
                          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

                          • Stephen Kay

                            #14
                            Re: newbie question: what is simple way to open a new url fromphp?

                            in article 4eu0229tjmj90e8 5aena9267psh1p1 l0b4@4ax.com, Geoff Berrow at
                            blthecat@ckdog. co.uk wrote on 3/21/06 5:10 PM:
                            [color=blue][color=green]
                            >> Now that I have the URL string (inside my php function), how do I call that
                            >> URL and get that page to open up in a window?[/color]
                            >
                            > I /think/ you'd probably have to use PHP to output some Javascript to do
                            > that.[/color]

                            Thanks for the reply.

                            I've since discovered curl for at least getting the page to display:

                            $ch = curl_init();
                            curl_setopt($ch , CURLOPT_URL, "http://www.eample.com" );
                            curl_exec ($ch);


                            --
                            Stephen Kay
                            Karma-Lab sk@karma-lab.NOSPAM.com
                            ^^^^^^^


                            Comment

                            Working...