472,364 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

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

gsb
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
Jul 17 '05 #1
19 4584
gsb wrote:
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?

<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 :
Jul 17 '05 #2
gsb
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
Jul 17 '05 #3
gsb wrote:
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>
I see.

Try this:

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


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 :
Jul 17 '05 #4
gsb
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
Jul 17 '05 #5
gsb wrote:
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


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>

Jul 17 '05 #6
gsb wrote:
That will send me back a blank page.
Yes, that is what I thought you wanted.
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.


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 :
Jul 17 '05 #7
gsb
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
Jul 17 '05 #8
"gsb" wrote
I had hoped for some PHP environment setting that would defeat the
"HTTP request/response protocol" and not send anything back.


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

Adriaan.
Jul 17 '05 #9
gsb
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
Jul 17 '05 #10
"gsb" <gs*@QWest.net> wrote in message news:<iJ***************@news.uswest.net>...
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.

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
Jul 17 '05 #11
"gsb" wrote
header("status: 204"); (or the other call)
header("HTTP/1.0 204 No Response");


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

Adriaan.
Jul 17 '05 #12
"Adriaan" <re*@de.solidareit> wrote in message news:<40***********************@dreader19.news.xs4 all.nl>...
"gsb" wrote
header("status: 204"); (or the other call)
header("HTTP/1.0 204 No Response");


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


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
Jul 17 '05 #13
"R. Rajesh Jeba Anbiah" wrote
...but then how you're going to send the file contents to the browser for download?


OP was talking about "uploading".


Ok :-)

Adriaan
Jul 17 '05 #14
gsb
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

gs*@qwest.net
Jul 17 '05 #15
gsb

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

gs*@qwest.net

Jul 17 '05 #16
"gsb" <gs*@qwest.net> schrieb im Newsbeitrag
news:5y*****************@news.uswest.net...
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


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
Jul 17 '05 #17
ng**********@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in
news:ab**************************@posting.google.c om:
"gsb" <gs*@QWest.net> wrote in message
news:<iJ***************@news.uswest.net>...

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

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


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

c

Jul 17 '05 #18
Chris Lott wrote:
ng**********@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in
news:ab**************************@posting.google.c om:
When posting please don't change the subject line
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.
and try to quote previous discussions. Your message is totally out of context.

Indeed.
You should get a decent newsreader that handles threading properly
That's sound advice as well. But the fact remains that
mid:iJ***************@news.uswest.net "is totally out of context".
-- the problem is yours, not the OPs.


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
Jul 17 '05 #19
"John Dunlop" wrote
(R. Rajesh Jeba Anbiah) wrote
When posting please don't change the subject line


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.


....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
Jul 17 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sarah | last post by:
Hi all. I have a form, and several text and image links on it that should submit the form with different actions. I prepared a simple page with just the code that's not working. PROBLEM:...
8
by: Syed Ali | last post by:
Hello, I have 1 HTML form with 4 submit buttons and 10 textfield entry areas. If submit button1 is pressed I need to make sure that all 10 textfield entries have been filled before submitting...
29
by: Mic | last post by:
Goal: delay execution of form submit Code (Javascript + JScript ASP): <% Response.Write("<OBJECT ID='IntraLaunch' STYLE='display : none' WIDTH=0 HEIGHT=0...
3
by: Matt | last post by:
When the user click the submit button in myform.asp, then it will invoke the javascript to check the form data. I want to know if we need document.myform.submit(); ?? Because even I comment it...
2
by: Margaret Werdermann | last post by:
Hi all: I'm having a nasty time with a particularly difficult piece of code and was hoping someone might be able to help me. I have a FormMail form that originally worked perfectly. Then, I...
13
by: John Kiernan | last post by:
Hey JavaScript gurus... I'm going to try this again. I haven't gotten as much help as I have advice on style<grin>. I appreciate (having programmed in other languages for quite a while) that...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
2
by: Mel | last post by:
i want to diable all submit_buttons untill all my form elements are populated. how can i do that ? thanks
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.