By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 23 '05 #1
Share this Question
Share on Google+
17 Replies


P: n/a
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.


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.
Jul 23 '05 #2

P: n/a
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


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

Jul 23 '05 #3

P: n/a
In article <40********@10.10.0.241>, Br**********@yahoo.com enlightened
us with...

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,

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?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

P: n/a
Berislav Lopac wrote:
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.


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/
Jul 23 '05 #5

P: n/a
kaeli wrote:
In article <40********@10.10.0.241>, Br**********@yahoo.com enlightened
us with...
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,

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.


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=stuff"></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

Jul 23 '05 #6

P: n/a
In article <40********@10.10.0.241>, Br**********@yahoo.com enlightened
us with...
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.
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.


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.
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=stuff"></SCRIPT>


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.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #7

P: n/a
kaeli wrote:
In article <40********@10.10.0.241>, Br**********@yahoo.com enlightened
us with...
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.


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.

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.

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=stuff"></SCRIPT>


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!


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

Jul 23 '05 #8

P: n/a
gsb
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
Jul 23 '05 #9

P: n/a
gsb
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
Jul 23 '05 #10

P: n/a
gsb
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
Jul 23 '05 #11

P: n/a
gsb
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

gs*@qwest.net

Jul 23 '05 #12

P: n/a
gsb wrote:
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.


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.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #13

P: n/a
gsb
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
Jul 23 '05 #14

P: n/a
gsb wrote:
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.

<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.
Jul 23 '05 #15

P: n/a
gsb
Richard,
...leaving you black-listing real e-mail
addresses belonging to people who have never sent you any e-mail


No. A misunderstanding. The buster does not ban anyone, just me manually.
If no response as per your scenario, the buster simply deletes the pending
email after 72-hours.
Not ban also, so subsequent emails are bran new to the process.

gsb

Jul 23 '05 #16

P: n/a
Richard Cornford wrote:
gsb wrote:
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).


Another is spammers sending mail, with a forged from: field, in the
hopes that it goes through, thereby "validating" - in a sense - the
email address, and then it adds it to a spam list.

That was the consequences that occurred to me when I emailed you and
asked if I missed something. Remember that?
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #17

P: n/a
Randy Webb wrote:
<snip>
That was the consequences that occurred to me when I emailed
you and asked if I missed something. Remember that?


Yes I remember that. The best clue as to whether a dubious e-mail is
really from me remains being aware that I am capable of composing a
meaningful subject line. :) (Apart from checking that the originating
server belongs to my ISP)

Richard.
Jul 23 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.