HOW TO: Submit a form to PHP with no return?

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

    #1

    HOW TO: Submit a form to PHP with no return?

    HOW TO: Submit a form to PHP with no return?

    I need to submit a form for file upload to a PHP script but do not want
    anything returned.
    That is the TARGET for the form should be like a null device.
    I am using a JavaScript function to submit the form.

    Is there a way to do this?

    gsb


  • Berislav Lopac

    #2
    Re: HOW TO: Submit a form to PHP with no return?

    gsb wrote:[color=blue]
    > HOW TO: Submit a form to PHP with no return?
    >
    > I need to submit a form for file upload to a PHP script but do not
    > want anything returned.
    > That is the TARGET for the form should be like a null device.
    > I am using a JavaScript function to submit the form.[/color]

    What do you mean that you do not want anything returned? A HTTP query always
    has a response; you can ingore it if you wish.

    Berislav

    --
    If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
    Groucho, Chico, and Harpo, then Usenet is Zeppo.


    Comment

    • Brian Genisio

      #3
      Re: HOW TO: Submit a form to PHP with no return?

      gsb wrote:
      [color=blue]
      > HOW TO: Submit a form to PHP with no return?
      >
      > I need to submit a form for file upload to a PHP script but do not want
      > anything returned.
      > That is the TARGET for the form should be like a null device.
      > I am using a JavaScript function to submit the form.
      >
      > Is there a way to do this?
      >
      > gsb
      >
      >[/color]

      There are two ways off the top of my head.

      The first is to use a hidden IFRAME, and ignore the result. Not all
      browsers support IFRAMEs.

      I have also seen a query hidden in an image:

      <IMG src="http://somewhere.com/form_submit.php ?data=some.data .is.here"
      width=0 height=0>

      The example shows a 0x0 image, but the most likely way to make it work
      in all systems is to actually return a 1x1 clear gif from the script.
      You can always put it in a floating DIV, and make it hidden. Lots of
      options.

      Brian

      Comment

      • kaeli

        #4
        Re: HOW TO: Submit a form to PHP with no return?

        In article <40977e5d$1@10. 10.0.241>, BrianGenisio@ya hoo.com enlightened
        us with...[color=blue]
        >
        > I have also seen a query hidden in an image:
        >
        > <IMG src="http://somewhere.com/form_submit.php ?data=some.data .is.here"
        > width=0 height=0>
        >
        > The example shows a 0x0 image, but the most likely way to make it work
        > in all systems is to actually return a 1x1 clear gif from the script.
        > You can always put it in a floating DIV, and make it hidden. Lots of
        > options.
        >[/color]

        Brian,

        Do you know if this works in most DOM browsers (NN/IE/Opera/Moz) if it
        returns a gif?
        This is cool. I could use this.


        --
        --
        ~kaeli~
        If a parsley farmer is sued, can they garnish his wages?



        Comment

        • Matt Kruse

          #5
          Re: HOW TO: Submit a form to PHP with no return?

          Berislav Lopac wrote:[color=blue]
          > What do you mean that you do not want anything returned? A HTTP query
          > always has a response; you can ingore it if you wish.[/color]

          Well, that's not _exactly_ true. One of the valid responses is "no response"
          :)

          No Response 204
          Server has received the request but there is no information to send back,
          and the client should stay in the same document view. This is mainly to
          allow input for scripts without changing the document at the same time.

          Have your PHP script return 204 as the status code, and the page will not be
          updated on the client.

          --
          Matt Kruse
          Javascript Toolbox: http://www.mattkruse.com/javascript/


          Comment

          • Brian Genisio

            #6
            Re: HOW TO: Submit a form to PHP with no return?

            kaeli wrote:
            [color=blue]
            > In article <40977e5d$1@10. 10.0.241>, BrianGenisio@ya hoo.com enlightened
            > us with...
            >[color=green]
            >>I have also seen a query hidden in an image:
            >>
            >><IMG src="http://somewhere.com/form_submit.php ?data=some.data .is.here"
            >>width=0 height=0>
            >>
            >>The example shows a 0x0 image, but the most likely way to make it work
            >>in all systems is to actually return a 1x1 clear gif from the script.
            >>You can always put it in a floating DIV, and make it hidden. Lots of
            >>options.
            >>[/color]
            >
            >
            > Brian,
            >
            > Do you know if this works in most DOM browsers (NN/IE/Opera/Moz) if it
            > returns a gif?
            > This is cool. I could use this.
            >
            >[/color]

            As far as I know, it should. The concept of a server-side dynamic image
            is not new. PHP, for instance, has a dynamic image library that is real
            easy to use.

            As far as the browser knows, it is getting a static image with the query
            paramaters (after the "?"). The PHP script then returns a GIF, JPEG or
            PNG image header (instead of "Content-type: text/plain\n\n") and pumps
            graphic data down.

            Now, since this is really just a PHP script, with query parameters, you
            can do anything with it... send it to a database, or whetever.

            Come to think of it, here is another method I have seen... this one is
            real easy, since an empty string works:

            <SCRIPT type="text/javascript"
            src="http://blah.com/junk.php?data=s tuff"></SCRIPT>

            Now, your PHP script (or whatever server-side you use) can return
            nothing, and there is no worry about. The browser will execute the 0
            length script, and move on.

            I dont see why all browsers would not support this either :)

            Brian



            Comment

            • kaeli

              #7
              Re: HOW TO: Submit a form to PHP with no return?

              In article <40979efa$1@10. 10.0.241>, BrianGenisio@ya hoo.com enlightened
              us with...[color=blue][color=green]
              > > Brian,
              > >
              > > Do you know if this works in most DOM browsers (NN/IE/Opera/Moz) if it
              > > returns a gif?
              > > This is cool. I could use this.
              > >
              > >[/color]
              >
              > As far as I know, it should. The concept of a server-side dynamic image
              > is not new. PHP, for instance, has a dynamic image library that is real
              > easy to use.
              >
              > As far as the browser knows, it is getting a static image with the query
              > paramaters (after the "?"). The PHP script then returns a GIF, JPEG or
              > PNG image header (instead of "Content-type: text/plain\n\n") and pumps
              > graphic data down.
              >
              > Now, since this is really just a PHP script, with query parameters, you
              > can do anything with it... send it to a database, or whetever.
              >[/color]

              Very cool.
              I've been wondering about a way to do background data processing for my
              intranet app without using script tags.
              I think this might work.
              [color=blue]
              > Come to think of it, here is another method I have seen... this one is
              > real easy, since an empty string works:
              >
              > <SCRIPT type="text/javascript"
              > src="http://blah.com/junk.php?data=s tuff"></SCRIPT>
              >[/color]

              I knew that one, but it doesn't work if script is disabled on the
              client.

              Hrm, any idea what happens to yours if users choose not to surf with
              images? I know a few people turn off images and some have text browsers,
              like Lynx.

              Thanks!

              --
              --
              ~kaeli~
              Reading while sunbathing makes you well red.



              Comment

              • Brian Genisio

                #8
                Re: HOW TO: Submit a form to PHP with no return?

                kaeli wrote:
                [color=blue]
                > In article <40979efa$1@10. 10.0.241>, BrianGenisio@ya hoo.com enlightened
                > us with...
                >[color=green][color=darkred]
                >>>Brian,
                >>>
                >>>Do you know if this works in most DOM browsers (NN/IE/Opera/Moz) if it
                >>>returns a gif?
                >>>This is cool. I could use this.
                >>>
                >>>[/color]
                >>
                >>As far as I know, it should. The concept of a server-side dynamic image
                >>is not new. PHP, for instance, has a dynamic image library that is real
                >>easy to use.
                >>
                >>As far as the browser knows, it is getting a static image with the query
                >>paramaters (after the "?"). The PHP script then returns a GIF, JPEG or
                >>PNG image header (instead of "Content-type: text/plain\n\n") and pumps
                >>graphic data down.
                >>
                >>Now, since this is really just a PHP script, with query parameters, you
                >>can do anything with it... send it to a database, or whetever.
                >>[/color]
                >
                >
                > Very cool.
                > I've been wondering about a way to do background data processing for my
                > intranet app without using script tags.
                > I think this might work.
                >
                >[color=green]
                >>Come to think of it, here is another method I have seen... this one is
                >>real easy, since an empty string works:
                >>
                >><SCRIPT type="text/javascript"
                >>src="http://blah.com/junk.php?data=s tuff"></SCRIPT>
                >>[/color]
                >
                > I knew that one, but it doesn't work if script is disabled on the
                > client.
                >
                > Hrm, any idea what happens to yours if users choose not to surf with
                > images? I know a few people turn off images and some have text browsers,
                > like Lynx.
                >
                > Thanks!
                >[/color]

                I would guess that the methods would fall apart in Lynx. I also dont
                know if images are turned off. I have not used these methods for
                background processing... only for dynamic scripts, and dynamic images.
                In both cases, if the scripts or images were not turned on, it didnt matter.

                B

                Comment

                • gsb

                  #9
                  Re: HOW TO: Submit a form to PHP with no return?

                  Yes. I have used both of these methods.
                  The iFrame messes up the refresh and back buttons.
                  The image, I use a new image object and send back, for example, 1x1 for true
                  or a 2x2 for false.
                  Works nice.

                  But in this case, the form ia a file upload form.
                  It needs to be submitted (I think) and not pushed as a GET on an image url.

                  What does the 204 header look like, say from php, header(...); ?
                  Anyone?

                  Thanks for the help.

                  gsb


                  Comment

                  • gsb

                    #10
                    Re: HOW TO: Submit a form to PHP with no return?

                    Matt Kruse,

                    Than you.
                    I would like to try this.
                    But what does the 204 header look like, say from php, header(...); ?+

                    Thanks for the help.

                    gsb


                    Comment

                    • gsb

                      #11
                      Re: HOW TO: Submit a form to PHP with no return?

                      Matt Kruse,

                      Thanks again, but never mind my last post.
                      I should take tom eto research first, then respond.

                      If you haven't used, HTTP Response 204 can be very convenient. 204 tells the
                      server to immediately termiante this request. This is helpful if you want a
                      javascript (or similar) client-side function to execute a server-side
                      function without refreshing or changing the current webpage. Great for
                      updating database, setting global variables, etc.
                      header("status: 204"); (or the other call)
                      header("HTTP/1.0 204 No Response");

                      gsb


                      Comment

                      • gsb

                        #12
                        Footnote: Works well, see example.

                        Footnote:

                        204 works well.

                        Send me an email if interested and I'll send you a link of the example.
                        Bare with my proactive "junk-mail" buster.

                        gsb

                        gsb@qwest.net



                        Comment

                        • Randy Webb

                          #13
                          Re: Footnote: Works well, see example.

                          gsb wrote:[color=blue]
                          > Footnote:
                          >
                          > 204 works well.
                          >
                          > Send me an email if interested and I'll send you a link of the example.
                          > Bare with my proactive "junk-mail" buster.[/color]

                          Why do you pro-actively use a "junk-mail" buster and then asked to be
                          emailed? Seems counter-intuitive. And, why not just post the link/URL here?

                          --
                          Randy
                          Chance Favors The Prepared Mind
                          comp.lang.javas cript FAQ - http://jibbering.com/faq/

                          Comment

                          • gsb

                            #14
                            Re: Footnote: Works well, see example.

                            The junk mail buster simply challenges each unknown address with an email
                            asking the sender to confirm that their email is not junk.
                            Click on link or simply reply as is. This is a one time only challenge.
                            Then the email is added to the approved list and the original is forwarded
                            to my real inbox.
                            Pending mail is held 72 hours for a response and then deleted if none.

                            Most spammers have no real return address and therefore get deleted after 72
                            hours without ever reaching my real inbox.
                            Those that do get through, I can manually ban by address or server, so it is
                            a one time annoyance only.

                            I get 30-50 junk mails a day.
                            This system usually works well, although my email server is down today. LOL

                            gsb


                            Comment

                            • Richard Cornford

                              #15
                              Re: Footnote: Works well, see example.

                              gsb wrote:[color=blue]
                              > The junk mail buster simply challenges each unknown address with an
                              > email asking the sender to confirm that their email is not junk.
                              > Click on link or simply reply as is. This is a one time only
                              > challenge. Then the email is added to the approved list and the
                              > original is forwarded to my real inbox.
                              > Pending mail is held 72 hours for a response and then deleted if none.
                              >
                              > Most spammers have no real return address and therefore get deleted
                              > after 72 hours without ever reaching my real inbox.
                              > Those that do get through, I can manually ban by address or server,
                              > so it is a one time annoyance only.[/color]
                              <snip>

                              One practice of spammes is to use a forged return address that is
                              genuine in the sense that it belongs to someone else, sometimes culled
                              from Usenet. Leaving your anti spam technique sending requests for
                              confirmation to real addresses belonging to people who have never sent
                              you any email. Those people will see your requests for confirmation as
                              spam and will not respond to it, leaving you black-listing real e-mail
                              addresses belonging to people who have never sent you any e-mail (up to
                              that point).

                              Richard.


                              Comment

                              Working...