Connecting Tech Pros Worldwide Forums | Help | Site Map

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

gsb
Guest
 
Posts: n/a
#1: Jul 17 '05
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
Guest
 
Posts: n/a
#2: Jul 17 '05

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.php">
<!-- ... -->

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 :
gsb
Guest
 
Posts: n/a
#3: Jul 17 '05

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


Pedro Graca
Guest
 
Posts: n/a
#4: Jul 17 '05

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 :
gsb
Guest
 
Posts: n/a
#5: Jul 17 '05

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


Terence
Guest
 
Posts: n/a
#6: Jul 17 '05

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="document.close();" /></html>

Pedro Graca
Guest
 
Posts: n/a
#7: Jul 17 '05

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('Location: 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 :
gsb
Guest
 
Posts: n/a
#8: Jul 17 '05

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


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(parent!=self)document.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


Adriaan
Guest
 
Posts: n/a
#9: Jul 17 '05

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


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


gsb
Guest
 
Posts: n/a
#10: Jul 17 '05

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


R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a
#11: Jul 17 '05

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


"gsb" <gsb@QWest.net> wrote in message news:<iJNlc.4$vW5.11121@news.uswest.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(parent!=self)document.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
Adriaan
Guest
 
Posts: n/a
#12: Jul 17 '05

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.


R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a
#13: Jul 17 '05

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


"Adriaan" <red@de.solidareit> wrote in message news:<4098afc2$0$14648$e4fe514c@dreader19.news.xs4 all.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
Adriaan
Guest
 
Posts: n/a
#14: Jul 17 '05

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


gsb
Guest
 
Posts: n/a
#15: Jul 17 '05

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


gsb
Guest
 
Posts: n/a
#16: Jul 17 '05

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



R. Rajesh Jeba Anbiah,

Returning the results to an invisible iFrame causes the Refresh and back
buttons of the browser (most) to screw up if pressed.
I did not like this option when I tried.

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



Markus Ernst
Guest
 
Posts: n/a
#17: Jul 17 '05

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


"gsb" <gsb@qwest.net> schrieb im Newsbeitrag
news:5yAlc.479$zQ4.89615@news.uswest.net...[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]

I just thaught of a way somehow like:

- submit the form as usual to $_SERVER['PHP_SELF']
- process form data
- send header("Location: ".$_SERVER['PHP_SELF']."?submitted=yes");
- Include that to the body tag: <?php if(isset($_GET['submitted'])) echo '
onLoad="history.back()"'; ?>

So you get back to where you want.

HTH
Markus


Chris Lott
Guest
 
Posts: n/a
#18: Jul 17 '05

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


ng4rrjanbiah@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in
news:abc4d8b8.0405042145.6753ff88@posting.google.c om:
[color=blue]
> "gsb" <gsb@QWest.net> wrote in message
> news:<iJNlc.4$vW5.11121@news.uswest.net>...[/color]
[color=blue][color=green]
>> 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.[/color]

You should get a decent newsreader that handles threading properly-- the
problem is yours, not the OPs.

c

John Dunlop
Guest
 
Posts: n/a
#19: Jul 17 '05

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


Chris Lott wrote:
[color=blue]
> ng4rrjanbiah@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in
> news:abc4d8b8.0405042145.6753ff88@posting.google.c om:
>[color=green]
> > When posting please don't change the subject line[/color][/color]

That's good advice in general, but needs qualifying: don't change the
Subject line unnecessarily, or to something meaningless. The defender
is charged with both offences, each punishable by unlimited killfile
time.

Knowing whether to change the Subject line is sometimes tricky, but,
if done, it ought to be done sensibly. I've changed this article's
Subject line to reflect its content.
[color=blue][color=green]
> > and try to quote previous discussions. Your message is totally out of context.[/color][/color]

Indeed.
[color=blue]
> You should get a decent newsreader that handles threading properly[/color]

That's sound advice as well. But the fact remains that
mid:iJNlc.4$vW5.11121@news.uswest.net "is totally out of context".
[color=blue]
> -- the problem is yours, not the OPs.[/color]

We know Google's interface isn't ideal, but would you care to explain
why you attribute the problem to R. Rajesh Jeba Anbiah?

You forgot to read <news:news.newusers.questions>, didn't you? I urge
you to familiarise yourself with the articles routinely posted there,
or their HTML-ised equals, before making yourself look yet more
ignorant [1] of the subject (pun unintended). HTH.

Have a great weekend. :-)


[1] "Ignorant" is often used pejoratively, but isn't here.

--
Jock
Adriaan
Guest
 
Posts: n/a
#20: Jul 17 '05

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


"John Dunlop" wrote
[color=blue]
> (R. Rajesh Jeba Anbiah) wrote[color=green][color=darkred]
> > > When posting please don't change the subject line[/color][/color]
>
> That's good advice in general, but needs qualifying: don't change the
> Subject line unnecessarily, or to something meaningless. The defender
> is charged with both offences, each punishable by unlimited killfile
> time.[/color]

....but above all I VERY MUCH welcome everyone to post their final solution
(in the very same thread) rather than only asking for help and not bothering
about posting the result. So, I welcome that specific post by gsb, though it
was missing the context and though the changed subject line was missing the
"(was: ...)" part.

Adriaan


Closed Thread


Similar PHP bytes