473,811 Members | 3,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4754
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.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 :
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="documen t.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('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 :
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(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
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

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

Similar topics

4
7798
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: The form won't submit if the link is clicked, but will submit if the SUBMIT button is clicked. I need to call a function to change the form's action according to user's input before it is submitted.
8
14648
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 the form. If submit button2 is pressed I need to make sure that only textfied1 is filled before submitting the form.
29
8787
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 CLASSID='CLSID:0AE533FE-B805-4FD6-8AE1-A619FBEE7A23' CODEBASE='IntraLaunch.CAB#version=5,0,0,3'>") Response.Write("<PARAM NAME='ImageLoc' VALUE='Null'>") Response.Write("<PARAM NAME='ImageSrc' VALUE='Null'>")
3
1429
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 out, formresponse.asp could still get the form data. //myform.asp <script type="text/javascript"> function checkformdata()
2
4901
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 had to add a JavaScript function to the Submit button to make a server function run when the form was submitted. Unfortunately, this JavaScript wouldn't run when the button was designated as a Submit, so I changed the button and placed a...
13
1767
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 everyone has their own opinion on HOW things should be done. However, if it does not comes AFTER helping me figure out my problem, please... (fill in your own polite way to say 'save the bandwidth'). I have code in a MouseUp of my save button...
8
3376
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 about in the submitted action. I'd therefore like to get rid of them by doing something like:
2
4946
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
4942
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 what I'd like to have happen :
10
6094
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 different results than when I use a javascript submit: form1.submit();. I think the javascript submit is working as it should, since I want the server to process an __EVENTTARGET posting. When I click the submit button, it does not process the...
0
9731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.