Is there a way??

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

    Is there a way??

    Ok, two forms that submit to the same page. Is there a way (on the
    receiving page) to know which form info came from??

    I tried to give the submit buttons different names but doesn't work.
    Like that:

    if($HTTP_POST_V ARS[submit] = 'monday')
    {
    echo "from monday";
    }


    Any thoughts??


    =============== ============
    Cleibe Souza
  • Tom Thackrey

    #2
    Re: Is there a way??


    On 23-Feb-2004, Cleibe Souza <ccs27@cornell. edu> wrote:
    [color=blue]
    > Ok, two forms that submit to the same page. Is there a way (on the
    > receiving page) to know which form info came from??
    >
    > I tried to give the submit buttons different names but doesn't work.
    > Like that:
    >
    > if($HTTP_POST_V ARS[submit] = 'monday')
    > {
    > echo "from monday";
    > }
    >
    >
    > Any thoughts??[/color]

    Yes, correct your coding:

    if ($HTTP_POST_VAR S['submit'] == 'monday')

    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • rush

      #3
      Re: Is there a way??

      "Cleibe Souza" <ccs27@cornell. edu> wrote in message
      news:MPG.1aa405 68a2d3c39198968 1@newsstand.cit .cornell.edu...[color=blue]
      > Ok, two forms that submit to the same page. Is there a way (on the
      > receiving page) to know which form info came from??
      >
      > I tried to give the submit buttons different names but doesn't work.
      > Like that:
      >
      > if($HTTP_POST_V ARS[submit] = 'monday')
      > {
      > echo "from monday";
      > }
      >
      >
      > Any thoughts??[/color]

      well, you coud have a hidden field in both named "postSource " and set it to
      different value in different forms.

      rush
      --
      Get your very own domain easily. Fast and professional customer service.



      Comment

      • Pedro Graca

        #4
        Re: Is there a way??

        Cleibe Souza wrote:[color=blue]
        > Ok, two forms that submit to the same page. Is there a way (on the
        > receiving page) to know which form info came from??
        >
        > I tried to give the submit buttons different names but doesn't work.[/color]

        Yes, it does :)
        [color=blue]
        > Like that:
        >
        > if($HTTP_POST_V ARS[submit] = 'monday')
        > {
        > echo "from monday";
        > }[/color]

        But not like that :-))

        Try like this, where the two buttons have the same name:

        HTML
        * <form ... >
        * <input type="submit" name="submit" value="monday"/>
        * </form>
        * ...
        * <form ... >
        * <input type="submit" name="submit" value="tuesday"/>
        * </form>

        and PHP
        * if (isset($_POST['submit']) && $_POST['submit'] == 'monday') {
        * echo 'from monday';
        * }


        or, having buttons with different names:
        HTML
        * <form ... >
        * <input type="submit" name="monday"/>
        * </form>
        * ...
        * <form ... >
        * <input type="submit" name="tuesday"/>
        * </form>

        and PHP
        * if (isset($_POST['monday'])) {
        * echo 'from monday';
        * }
        --
        --= my mail box only accepts =--
        --= Content-Type: text/plain =--
        --= Size below 10001 bytes =--

        Comment

        • Chung Leong

          #5
          Re: Is there a way??

          Uzytkownik "Tom Thackrey" <use.signature@ nospam.com> napisal w wiadomosci
          news:F2r_b.1638 1$TC7.16077@new ssvr29.news.pro digy.com...[color=blue]
          >
          > On 23-Feb-2004, Cleibe Souza <ccs27@cornell. edu> wrote:
          >[color=green]
          > > Ok, two forms that submit to the same page. Is there a way (on the
          > > receiving page) to know which form info came from??
          > >
          > > I tried to give the submit buttons different names but doesn't work.
          > > Like that:
          > >
          > > if($HTTP_POST_V ARS[submit] = 'monday')
          > > {
          > > echo "from monday";
          > > }
          > >
          > >
          > > Any thoughts??[/color]
          >
          > Yes, correct your coding:
          >
          > if ($HTTP_POST_VAR S['submit'] == 'monday')[/color]

          PHP would have intrepreted the bare string as 'submit' so that's not the
          problem. I think the name of the submit is 'monday', hence the code should
          be

          if($HTTP_POST_V ARS['monday'])
          {
          echo "from monday";
          }
          else {
          echo "not from monday";
          }


          Comment

          • Tom Thackrey

            #6
            Re: Is there a way??


            On 23-Feb-2004, "Chung Leong" <chernyshevsky@ hotmail.com> wrote:
            [color=blue]
            > Uzytkownik "Tom Thackrey" <use.signature@ nospam.com> napisal w wiadomosci
            > news:F2r_b.1638 1$TC7.16077@new ssvr29.news.pro digy.com...[color=green]
            > >
            > > On 23-Feb-2004, Cleibe Souza <ccs27@cornell. edu> wrote:
            > >[color=darkred]
            > > > Ok, two forms that submit to the same page. Is there a way (on the
            > > > receiving page) to know which form info came from??
            > > >
            > > > I tried to give the submit buttons different names but doesn't work.
            > > > Like that:
            > > >
            > > > if($HTTP_POST_V ARS[submit] = 'monday')
            > > > {
            > > > echo "from monday";
            > > > }
            > > >
            > > >
            > > > Any thoughts??[/color]
            > >
            > > Yes, correct your coding:
            > >
            > > if ($HTTP_POST_VAR S['submit'] == 'monday')[/color]
            >
            > PHP would have intrepreted the bare string as 'submit' so that's not the
            > problem. I think the name of the submit is 'monday', hence the code should
            > be
            >
            > if($HTTP_POST_V ARS['monday'])
            > {
            > echo "from monday";
            > }
            > else {
            > echo "not from monday";
            > }[/color]

            You may be right, he didn't post the HTML. The problem I was pointing out
            was the ASSIGNMENT (=) in the if instead of EQUALITY (==)

            --
            Tom Thackrey

            tom (at) creative (dash) light (dot) com
            do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

            Comment

            Working...