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

G

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
 
B

Berislav Lopac

gsb said:
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
 
B

Brian Genisio

gsb said:
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
 
K

kaeli

[email protected] enlightened said:
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.


--
 
M

Matt Kruse

Berislav said:
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.
 
B

Brian Genisio

kaeli said:
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
 
K

kaeli

[email protected] enlightened said:
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!

--
 
B

Brian Genisio

kaeli said:
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.



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
 
G

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
 
G

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
 
G

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
 
G

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

(e-mail address removed)
 
R

Randy Webb

gsb said:
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?
 
G

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
 
R

Richard Cornford

gsb said:
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.
 
G

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
 
R

Randy Webb

Richard said:
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?
 
R

Richard Cornford

Randy Webb wrote:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top