RE: [PHP] Form duplicate post problem

2002-12-29 Thread Pag



You can still use one page and use a middle-man technique. The part
that processes the form input would redirect back to itself after the
data is inserted into the database, thus getting rid of the post data.
So subsequent refreshes of the page will refresh without attempting to
repost the data.


This post is merely for reference and, hopefully, to help out some 
other person that runs into the same problem.

I solved my duplicate form post problem using that middle-man 
technique you guys mentioned, but i did it in a little more user friendly 
way than using a complete page and redirecting back to the original. (thus 
preventing some design problems on my specific site)

I used some javascript to open a small window, it has the code to 
insert the comment into the database, thanks for the user input and 
immediately closes and refreshes the original, showing that last inserted 
comment. Works very smoothly, and if the user connection is fast enough, he 
doesnt even notice the window.

If anyone needs the code, feel free to email me, ok? I am just not 
posting it because its a bit long, and might unnecessarily clutter the 
list. :-)

Thanks for all the help, guys, you got me in the right direction.

Pag 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Form duplicate post problem

2002-12-29 Thread John W. Holmes
 You can still use one page and use a middle-man technique. The part
 that processes the form input would redirect back to itself after the
 data is inserted into the database, thus getting rid of the post
data.
 So subsequent refreshes of the page will refresh without attempting
to
 repost the data.
 
  This post is merely for reference and, hopefully, to help out
 some
 other person that runs into the same problem.
 
  I solved my duplicate form post problem using that middle-man
 technique you guys mentioned, but i did it in a little more user
friendly
 way than using a complete page and redirecting back to the original.
(thus
 preventing some design problems on my specific site)
 
  I used some javascript to open a small window, it has the
code to
 insert the comment into the database, thanks for the user input and
 immediately closes and refreshes the original, showing that last
inserted
 comment. Works very smoothly, and if the user connection is fast
enough,
 he
 doesnt even notice the window.
 

Also for reference, but I would recommend to everyone that they not rely
on Javascript and simply do all of this in the main window. With Pop-Up
Blockers and different browser versions, Javascript should be avoided if
possible unless you really know what your audience will be using (or
don't care).

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Form duplicate post problem

2002-12-29 Thread Pag



Also for reference, but I would recommend to everyone that they not rely
on Javascript and simply do all of this in the main window. With Pop-Up
Blockers and different browser versions, Javascript should be avoided if
possible unless you really know what your audience will be using (or
don't care).


I subscribe to your opinion, i spoke too soon. It seems i cant 
pass the form vars to the new javascript window, and i dont have a clue why 
not!
Quite simply, if instead of opening a new window, i use the exact 
same code on the main window, all the vars are passed, if i use javascript 
to open a new window, no php vars are passed on.
So i apologize for my early cry of victory, it quickly turned into 
a cry of despair. bah. Any ideas on how to get it working? PHP doesnt pass 
vars to javascript new window?

(going for the main window approach for now, thanks john)

Pag 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Form duplicate post problem

2002-12-29 Thread Jason Wong
On Sunday 29 December 2002 23:24, Pag wrote:

  This post is merely for reference and, hopefully, to help out some
 other person that runs into the same problem.

  I solved my duplicate form post problem using that middle-man
 technique you guys mentioned, but i did it in a little more user friendly
 way than using a complete page and redirecting back to the original. (thus
 preventing some design problems on my specific site)

  I used some javascript to open a small window, it has the code to
 insert the comment into the database, thanks for the user input and
 immediately closes and refreshes the original, showing that last inserted
 comment. Works very smoothly, and if the user connection is fast enough, he
 doesnt even notice the window.

Maybe I'm missing something here but I'm not sure why you consider it more 
user friendly to pop-up a window (and have it disappear automatically). If I 
was a user I would be thinking what the hell was that?. And if their 
connection was fast enough that they don't even notice the window pop-up  
disappear, and just see the main page refresh how different is that to the 
'one page and use a middle-man technique'?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
If *I* had a hammer, there'd be no more folk singers.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Form duplicate post problem

2002-12-29 Thread Pag



Maybe I'm missing something here but I'm not sure why you consider it more
user friendly to pop-up a window (and have it disappear automatically). If I
was a user I would be thinking what the hell was that?. And if their
connection was fast enough that they don't even notice the window pop-up 
disappear, and just see the main page refresh how different is that to the
'one page and use a middle-man technique'?


Ok, i admit my donkeyness. :-P It takes the same time to popup, 
close and refresh, than it does to redirect and refresh.
One thing that popup would prevent would be the browser history, i 
mean, if that popup method worked, if the user clicked on the back 
browser button, it would take him to where he came from. If i use that 
redirect method, the back button takes him to the redirect. Still trying to 
figure that one out. Would be nice to make the browser history forget 
that redirect. :-P
But you are right, Jason, time wise i was wrong in going for the 
popup, not to mention those other very relevant facts john mentioned too.

Pag 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Form duplicate post problem

2002-12-29 Thread Jason Wong
On Monday 30 December 2002 01:40, Pag wrote:

  One thing that popup would prevent would be the browser history, i
 mean, if that popup method worked, if the user clicked on the back
 browser button, it would take him to where he came from. If i use that
 redirect method, the back button takes him to the redirect. Still trying to
 figure that one out. Would be nice to make the browser history forget
 that redirect. :-P

I don't think a server redirect shows up on the browser's history list! Try 
it.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Politics, as a practice, whatever its professions, has always been the
systematic organisation of hatreds.
-- Henry Adams, The Education of Henry Adams
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Form duplicate post problem

2002-12-29 Thread John W. Holmes
   One thing that popup would prevent would be the browser
 history, i
  mean, if that popup method worked, if the user clicked on the back
  browser button, it would take him to where he came from. If i use
that
  redirect method, the back button takes him to the redirect. Still
trying
 to
  figure that one out. Would be nice to make the browser history
forget
  that redirect. :-P
 
 I don't think a server redirect shows up on the browser's history
list!
 Try
 it.

Yeah, you should be using a header() redirect, not a javascript or META
REFRESH redirect...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Form duplicate post problem

2002-12-29 Thread Pag



Yeah, you should be using a header() redirect, not a javascript or META
REFRESH redirect...


Well, i tried, but i get an error saying that all the headers were 
already sent to the browser. :-P
I used:

header('Location: http://www.blahblah.com etc');


I placed this header right after all the database writes.

Pag 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Form duplicate post problem

2002-12-29 Thread Michael J. Pawlowsky
2 ways around that.. make sure you send that before any other ouput...  Even empty 
lines etc In other words nothing before ?php and nothing after ? Not ever a 
carriage return.

or start of with ob_start() and end with ob_end_flush();



*** REPLY SEPARATOR  ***

On 29/12/2002 at 7:12 PM Pag wrote:


Yeah, you should be using a header() redirect, not a javascript or META
REFRESH redirect...

 Well, i tried, but i get an error saying that all the headers
were
already sent to the browser. :-P
 I used:

 header('Location: http://www.blahblah.com etc');


 I placed this header right after all the database writes.

 Pag



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Form duplicate post problem

2002-12-29 Thread John W. Holmes
 Yeah, you should be using a header() redirect, not a javascript or
META
 REFRESH redirect...
 
  Well, i tried, but i get an error saying that all the headers
 were
 already sent to the browser. :-P
  I used:
 
  header('Location: http://www.blahblah.com etc');
 
 
  I placed this header right after all the database writes.

Well, yeah, the idea is that you don't output anything on the
middle-man page, only do your inserts and that's it. 

The error message tells you exactly where the output is starting, if
that's a mystery to you (output started in file.php:2 means line 2 of
file.php).

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Form duplicate post problem

2002-12-29 Thread Jason Sheets
You can also enable output buffering on your middle page, this will
allow you to output data and set cookies, send headers, etc at any point
in your script.

You can enable output buffering globally with php.ini, with an .htaccess
for specific directories or use the output buffering functions to enable
them for just a script or even part of a script.


Jason
On Sun, 2002-12-29 at 12:29, John W. Holmes wrote:
  Yeah, you should be using a header() redirect, not a javascript or
 META
  REFRESH redirect...
  
   Well, i tried, but i get an error saying that all the headers
  were
  already sent to the browser. :-P
   I used:
  
   header('Location: http://www.blahblah.com etc');
  
  
   I placed this header right after all the database writes.
 
 Well, yeah, the idea is that you don't output anything on the
 middle-man page, only do your inserts and that's it. 
 
 The error message tells you exactly where the output is starting, if
 that's a mystery to you (output started in file.php:2 means line 2 of
 file.php).
 
 ---John W. Holmes...
 
 PHP Architect - A monthly magazine for PHP Professionals. Get your copy
 today. http://www.phparch.com/
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Form duplicate post problem

2002-12-29 Thread Pag

	Got it to work. I removed everything except the PHP script. Works like a 
charm, no problem on the browser back button.
	Great help from you guys. Thanks a lot!

	Pag



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Form duplicate post problem

2002-12-28 Thread Pag

	Hi,

	I am having some problems with duplicate form input.
	I have a form that adds comments to an article, works fine, but if the 
user clicks on refresh, having added a comment previously, the same 
comment is added again. I tried clearing the variables after the database 
write, but the refresh somehow resends the previous values.
	Roughly, heres how my script works: (not using actual code syntax here)

	--
	if {$flag=1 AND $name!='' AND $commentbody!=''){

	inserts the comment into the database
	$flag = 0
	$name = ''
	$comment = ''
	}
	--
	routine to display the article and the existing comments here
	--
	form here
	if user clicks send, puts $flag=1 and calls same page
	--


	How can i prevent these double entries? Some command to definitely clear 
the variables?
	Thanks.

	Pag



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Form duplicate post problem

2002-12-28 Thread Timothy Hitchens (HiTCHO)
There is a very simple solution to this on the page that
does the entries into the database simply to a header redirect
to a new page that displays the success notices etc and if they
do a back or a refresh nothing will happen as the POST data
is on the previous now removed from history page.

header('Location: http://www.yourdomain.com/success.html');

* you will need to put some GET data in the URL to show the correct page.

That will do it for you.

Remember that you can't send output on the database entry page simple
to the database calls and they do the header call as above.



Timothy Hitchens (HiTCHO)
[EMAIL PROTECTED]


If you need PHP hosting with an experienced
support team 24/7 then email me today.

On Sun, 29 Dec 2002, Pag wrote:


   Hi,

   I am having some problems with duplicate form input.
   I have a form that adds comments to an article, works fine, but if the
 user clicks on refresh, having added a comment previously, the same
 comment is added again. I tried clearing the variables after the database
 write, but the refresh somehow resends the previous values.
   Roughly, heres how my script works: (not using actual code syntax here)

   --
   if {$flag=1 AND $name!='' AND $commentbody!=''){

   inserts the comment into the database
   $flag = 0
   $name = ''
   $comment = ''
   }
   --
   routine to display the article and the existing comments here
   --
   form here
   if user clicks send, puts $flag=1 and calls same page
   --


   How can i prevent these double entries? Some command to definitely clear
 the variables?
   Thanks.

   Pag



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Form duplicate post problem

2002-12-28 Thread Pag




to a new page that displays the success notices etc and if they
do a back or a refresh nothing will happen as the POST data
is on the previous now removed from history page.


I understand, but the reason i am trying to stick with just one 
page is that i want it to be practical. I mean, the moment the user clicks 
submit the page reloads and shows his comment immediately, and give him 
the functionality of pressing refresh to see if anyone else commented in 
the meantime.
Also, by using a different page, even with a redirect back to the 
original, might take a little while, since the original is a bit heavy on 
the download side. ;-)

Pag 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Form duplicate post problem

2002-12-28 Thread John W. Holmes
 to a new page that displays the success notices etc and if they
 do a back or a refresh nothing will happen as the POST data
 is on the previous now removed from history page.
 
  I understand, but the reason i am trying to stick with just
one
 page is that i want it to be practical. I mean, the moment the user
clicks
 submit the page reloads and shows his comment immediately, and give
him
 the functionality of pressing refresh to see if anyone else commented
in
 the meantime.
  Also, by using a different page, even with a redirect back to
the
 original, might take a little while, since the original is a bit heavy
on
 the download side. ;-)

You can still use one page and use a middle-man technique. The part
that processes the form input would redirect back to itself after the
data is inserted into the database, thus getting rid of the post data.
So subsequent refreshes of the page will refresh without attempting to
repost the data. 

The only other way to do it is to check the data you're about to insert
to see if it's already there. If it is, then don't insert it...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Form duplicate post problem

2002-12-28 Thread Timothy Hitchens (HiTCHO)
The redirect using the header method is instant and if the middle
page just does the inserts and you redirect right away using PHP
it is not noticable at all.


Timothy Hitchens (HiTCHO)
[EMAIL PROTECTED]


If you need PHP hosting with an experienced
support team 24/7 then email me today.

On Sun, 29 Dec 2002, Pag wrote:




 to a new page that displays the success notices etc and if they
 do a back or a refresh nothing will happen as the POST data
 is on the previous now removed from history page.

  I understand, but the reason i am trying to stick with just one
 page is that i want it to be practical. I mean, the moment the user clicks
 submit the page reloads and shows his comment immediately, and give him
 the functionality of pressing refresh to see if anyone else commented in
 the meantime.
  Also, by using a different page, even with a redirect back to the
 original, might take a little while, since the original is a bit heavy on
 the download side. ;-)

  Pag





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Form duplicate post problem

2002-12-28 Thread Pag



The redirect using the header method is instant and if the middle
page just does the inserts and you redirect right away using PHP
it is not noticable at all.



I gave up on reinventing the wheel and i am trying to use that 
middle-page method you guys mentioned. To make things a little more 
transparent to the user, i thought of using a popup window instead, you 
know, a tiny window pops up, with the code to insert the comment on the 
database, and closes right after it does so.

but err..how can i close it right after the database insert?

Pag 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Form duplicate post problem

2002-12-28 Thread Michael J. Pawlowsky


You can close it with JavaScript.

Something like

script language=JavaScript
function open_a_window_please(){
lovechild = window.open(childpage.htm);
/script

Now we have a name that can tell the browser which window to close.
We're ready to use the window.close() method. In the parent page add the following 
closing link:

body
a href=javascript: open_a_window_please()Click here to open a window./a
a href=javascript:lovechild.close()Click here to close the child window./a
/body


Dont forget you will need to use flush betwen your major parts otherwise it might 
not get sent to the browser right away.

Mike

P.S. Alot of PC's dont allow window.open anymore. People install ad blockers so it 
doesn't work.


*** REPLY SEPARATOR  ***



 I gave up on reinventing the wheel and i am trying to use that
middle-page method you guys mentioned. To make things a little more
transparent to the user, i thought of using a popup window instead, you
know, a tiny window pops up, with the code to insert the comment on the
database, and closes right after it does so.

 but err..how can i close it right after the database insert?

 Pag



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php