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

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

    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


  • Pedro Graca

    #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.
    >
    > Is there a way to do this?[/color]


    <form method="post" action="null.ph p">
    <!-- ... -->

    and

    <?php // null.php
    // deal with file upload
    // *with no* output to the browser

    // and then ...
    // ...
    // ...



    exit(0);
    ?>


    What is this for?

    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    • gsb

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

      Pedro Graca,

      Thanks for a quick reply.
      However, it does not seem to work.
      The target defaults to self and the browser window simply goes blank.

      Here is what I get back:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      <HTML><HEAD>
      <META http-equiv=Content-Type content="text/html;
      charset=windows-1252"></HEAD>
      <BODY></BODY></HTML>

      It is for a simple upload page without feedback.
      ....but I can not make it quiet.

      gsb


      Comment

      • Pedro Graca

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

        gsb wrote:[color=blue]
        > Pedro Graca,
        >
        > Thanks for a quick reply.
        > However, it does not seem to work.
        > The target defaults to self and the browser window simply goes blank.
        >
        > Here is what I get back:
        ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        ><HTML><HEAD>
        ><META http-equiv=Content-Type content="text/html;
        > charset=windows-1252"></HEAD>
        ><BODY></BODY></HTML>[/color]

        I see.

        Try this:

        <?php
        // deal with upload
        header('Content-Type: text/plain; charset=us-ascii');
        echo '';
        ?>
        [color=blue]
        > It is for a simple upload page without feedback.
        > ...but I can not make it quiet.[/color]

        Why?
        Why no feedback?

        Not even a simple

        Thank you for uploading the file whatever.zip
        Now close your browser and go read a book :-)

        --
        USENET would be a better place if everybody read: : mail address :
        http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
        http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
        http://www.expita.com/nomime.html : to 10K bytes :

        Comment

        • gsb

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

          Pedro Graca,

          That will send me back a blank page.

          Why?
          I have a one page site that should not be reloaded due to possible user
          rearrangement.
          I do not want a popup nor internal iFrame.
          So I would like the server to simply not respond or redirect any 'required'
          output to a null device or non-existing window.

          The file checks and user feed back come from elsewhere.

          gsb


          Comment

          • Terence

            #6
            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]

            gsb, when someone uses a form such as for the purposes of obloading,
            that form sends a request to the web server containing the uploaded data.

            Because HTTP is a request/response protocol, your browser will "allways"
            wait for and act on a response that the server will inevitably
            provide (if nothing breaks).

            Hence, you always have to put whatever you want to come next in a page
            pointed to by the form action attribute.

            If you don't want the screen to change, then point the action attribute
            to the same file containing the form we are talking about.

            A nice trick would be to use the onSubmit javascript event attribute in
            the form element to pop up a new window which is also then specified in
            the target element of the form attribute. The action attribute in the
            form element can then point to a handling script which doesn't output
            anything other than
            <html><head/><body onload="documen t.close();" /></html>

            Comment

            • Pedro Graca

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

              gsb wrote:[color=blue]
              > That will send me back a blank page.[/color]

              Yes, that is what I thought you wanted.
              [color=blue]
              > Why?
              > I have a one page site that should not be reloaded due to possible user
              > rearrangement.
              > I do not want a popup nor internal iFrame.
              > So I would like the server to simply not respond or redirect any 'required'
              > output to a null device or non-existing window.[/color]

              Ah! Maybe your real problem is the "Back/Refresh" one :)

              If that is it, I do like something like this:

              1. Server sends the form to the browser (GET form.php)
              2. User fills the form and submits (POST dealform.php)
              3. Server deals with data and redirectes (header('Locati on: tak.php');)
              4. User sees the "Thank you" page (GET tak.php)

              If the user now presses Refresh he will be refreshing the GET, not the
              POST; and if he presses Back he will be taken to 1. (again the GET and
              not the POST)


              HTH

              --
              USENET would be a better place if everybody read: : mail address :
              http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
              http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
              http://www.expita.com/nomime.html : to 10K bytes :

              Comment

              • gsb

                #8
                My work around...

                Well, thank you both.
                I now know more than before.

                I had hoped for some PHP environment setting that would defeat the "HTTP
                request/response protocol" and not send anything back.

                So, I will use an internal, dynamically created iFrame and return the very
                same page (I only have one page) with an onLoad check like:

                <BODY onLoad="if(pare nt!=self)docume nt.close();">

                That will insure that the browser's refresh and back methods will redirect
                to itself. Page components are already cached so I expect minimal impact on
                performance.

                Again, thanks for your time and help.
                If you think of anything else, please post: I'll be glad to look.

                gsb


                Comment

                • Adriaan

                  #9
                  Re: My work around...

                  "gsb" wrote[color=blue]
                  > I had hoped for some PHP environment setting that would defeat the
                  > "HTTP request/response protocol" and not send anything back.[/color]

                  ....so the browser, which does not know about that setting for that specific
                  website, would show a "request timed out"?

                  Adriaan.


                  Comment

                  • gsb

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

                    In a Javascript newsgroup, Matt Kruse led me to this:

                    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");

                    Thought that y'all might like to know.

                    gsb


                    Comment

                    • R. Rajesh Jeba Anbiah

                      #11
                      Re: My work around...

                      "gsb" <gsb@QWest.ne t> wrote in message news:<iJNlc.4$v W5.11121@news.u swest.net>...[color=blue]
                      > Well, thank you both.
                      > I now know more than before.
                      >
                      > I had hoped for some PHP environment setting that would defeat the "HTTP
                      > request/response protocol" and not send anything back.
                      >
                      > So, I will use an internal, dynamically created iFrame and return the very
                      > same page (I only have one page) with an onLoad check like:
                      >
                      > <BODY onLoad="if(pare nt!=self)docume nt.close();">
                      >
                      > That will insure that the browser's refresh and back methods will redirect
                      > to itself. Page components are already cached so I expect minimal impact on
                      > performance.
                      >
                      > Again, thanks for your time and help.
                      > If you think of anything else, please post: I'll be glad to look.[/color]


                      When posting please don't change the subject line and try to quote
                      previous discussions. Your message is totally out of context.

                      --
                      | Just another PHP saint |
                      Email: rrjanbiah-at-Y!com

                      Comment

                      • Adriaan

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

                        "gsb" wrote[color=blue]
                        > header("status: 204"); (or the other call)
                        > header("HTTP/1.0 204 No Response");[/color]

                        ....but then how you're going to send the file contents to the browser for
                        download?

                        Adriaan.


                        Comment

                        • R. Rajesh Jeba Anbiah

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

                          "Adriaan" <red@de.solidar eit> wrote in message news:<4098afc2$ 0$14648$e4fe514 c@dreader19.new s.xs4all.nl>...[color=blue]
                          > "gsb" wrote[color=green]
                          > > header("status: 204"); (or the other call)
                          > > header("HTTP/1.0 204 No Response");[/color]
                          >
                          > ...but then how you're going to send the file contents to the browser for
                          > download?[/color]

                          OP was talking about "uploading" .

                          FWIW, in a similar discussions Chung Leong was suggested to post the
                          form to a invisible IFRAME.

                          --
                          | Just another PHP saint |
                          Email: rrjanbiah-at-Y!com

                          Comment

                          • Adriaan

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

                            "R. Rajesh Jeba Anbiah" wrote[color=blue][color=green]
                            > > ...but then how you're going to send the file contents to the browser[/color][/color]
                            for[color=blue][color=green]
                            > > download?[/color]
                            >
                            > OP was talking about "uploading" .[/color]

                            Ok :-)

                            Adriaan


                            Comment

                            • gsb

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

                              Adriaan,

                              By that point, the file contents are already on the server and stowed away.

                              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

                              Working...