Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old July 23rd, 2005, 11:41 AM
gsb
Guest
 
Posts: n/a
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


  #2  
Old July 23rd, 2005, 11:41 AM
Berislav Lopac
Guest
 
Posts: n/a

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.[/color]

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.


  #3  
Old July 23rd, 2005, 11:42 AM
Brian Genisio
Guest
 
Posts: n/a

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]

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

  #4  
Old July 23rd, 2005, 11:42 AM
kaeli
Guest
 
Posts: n/a

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


In article <40977e5d$1@10.10.0.241>, BrianGenisio@yahoo.com enlightened
us with...[color=blue]
>
> 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.
>[/color]

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

  #5  
Old July 23rd, 2005, 11:42 AM
Matt Kruse
Guest
 
Posts: n/a

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


Berislav Lopac wrote:[color=blue]
> 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.[/color]

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/


  #6  
Old July 23rd, 2005, 11:42 AM
Brian Genisio
Guest
 
Posts: n/a

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


kaeli wrote:
[color=blue]
> In article <40977e5d$1@10.10.0.241>, BrianGenisio@yahoo.com enlightened
> us with...
>[color=green]
>>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.
>>[/color]
>
>
> 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.
>
>[/color]

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



  #7  
Old July 23rd, 2005, 11:42 AM
kaeli
Guest
 
Posts: n/a

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


In article <40979efa$1@10.10.0.241>, BrianGenisio@yahoo.com enlightened
us with...[color=blue][color=green]
> > 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.
> >
> >[/color]
>
> 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.
>[/color]

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.
[color=blue]
> 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>
>[/color]

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

  #8  
Old July 23rd, 2005, 11:42 AM
Brian Genisio
Guest
 
Posts: n/a

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


kaeli wrote:
[color=blue]
> In article <40979efa$1@10.10.0.241>, BrianGenisio@yahoo.com enlightened
> us with...
>[color=green][color=darkred]
>>>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.
>>>
>>>[/color]
>>
>>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.
>>[/color]
>
>
> 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.
>
>[color=green]
>>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>
>>[/color]
>
> 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!
>[/color]

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

  #9  
Old July 23rd, 2005, 11:42 AM
gsb
Guest
 
Posts: n/a

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


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


  #10  
Old July 23rd, 2005, 11:42 AM
gsb
Guest
 
Posts: n/a

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


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


  #11  
Old July 23rd, 2005, 11:42 AM
gsb
Guest
 
Posts: n/a

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


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


  #12  
Old July 23rd, 2005, 11:45 AM
gsb
Guest
 
Posts: n/a

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


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

gsb@qwest.net



  #13  
Old July 23rd, 2005, 11:45 AM
Randy Webb
Guest
 
Posts: n/a

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


gsb wrote:[color=blue]
> 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.[/color]

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/
  #14  
Old July 23rd, 2005, 11:45 AM
gsb
Guest
 
Posts: n/a

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


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


  #15  
Old July 23rd, 2005, 11:47 AM
Richard Cornford
Guest
 
Posts: n/a

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


gsb wrote:[color=blue]
> 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.[/color]
<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.


  #16  
Old July 23rd, 2005, 11:47 AM
gsb
Guest
 
Posts: n/a

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


Richard,
[color=blue]
> ...leaving you black-listing real e-mail
> addresses belonging to people who have never sent you any e-mail[/color]

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



  #17  
Old July 23rd, 2005, 11:47 AM
Randy Webb
Guest
 
Posts: n/a

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


Richard Cornford wrote:
[color=blue]
> 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).
>[/color]

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/
  #18  
Old July 23rd, 2005, 11:47 AM
Richard Cornford
Guest
 
Posts: n/a

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


Randy Webb wrote:
<snip>[color=blue]
> That was the consequences that occurred to me when I emailed
> you and asked if I missed something. Remember that?[/color]

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.


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO: Submit a form to PHP with no return? gsb answers 19 July 17th, 2005 06:10 AM