Re: [PHP] Browser reload problem

2004-07-30 Thread Jason Barnett
Is there a question here?  Or is this a resolution?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Browser reload problem

2004-07-30 Thread Ashley M. Kirchner
Jason Barnett wrote:
Is there a question here?  Or is this a resolution?
   Thanks for asking.  I found a solution that works.  Basically when 
data gets returned, check the unique id against the DB.  If it doesn't 
exist, insert it together with the other stuff I want in the DB.  If it 
does, don't bother re-adding it - don't return an error either because 
the user won't care anyway.

   Though I'm intrigued by two things: a) why am I getting both 
$_REQUEST as well as $_POST variables when I get PayPal's redirect, and 
b) I wonder if Matthew Sims' solution of inserting a header redirect 
back to the same page really discards all of the $_POST variables.  And 
if so, what happens with the $_REQUEST ones?

--
W | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.

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


RE: [PHP] Browser reload problem

2004-07-30 Thread Ford, Mike [LSS]
On 30 July 2004 16:25, Ashley M. Kirchner wrote:

 Jason Barnett wrote:
 
 Though I'm intrigued by two things: a) why am I getting both
 $_REQUEST as well as $_POST variables

Because $_REQUEST is an aggregate of $_GET, $_POST and $_COOKIE.  That's the way it's 
defined: see 
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.request.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Browser reload problem

2004-07-29 Thread Skippy
Quoting Ashley M. Kirchner [EMAIL PROTECTED]:
 PayPal passes a ton of data back to us when someone's done 
 purchasing something.  I use some of that information and shove it all 
 into a database.  Problem is, if someone hits reload on their browser, I 
 get the same data re-inserted again.  Reload the page four times, and I 
 will get four records with the same data inserted.  How can I avoid 
 this?  I'd like to silently either discard the information after it's 
 been inserted, or silently prevent it from being re-inserted again.

1. Receive PayPal data in your script.
2. Process it (stick into database).
3. Redirect to another script and forward any data you want displayed.
4. Have the 2nd script show whatever confirmation message you want.

The user can now reload all he wants, he gets just the 2nd script
which doesn't do anything but display the same message over and over.

ATTENTION: if you receive the PayPal data by POST be sure to redirect
using 303 See Other, which will deactivate the POST and force the
redirect to use GET. Of course, forwarding any data to the 2nd script
should be done as GET parameters.

Or, even better, just forward the 2nd script the database ID of the
data you just recorded and if it needs to display anything it can get
it from there.

-- 
Romanian Web Developers - http://ROWD.ORG

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



Re: [PHP] Browser reload problem

2004-07-29 Thread Matthew Sims

 PayPal passes a ton of data back to us when someone's done
 purchasing something.  I use some of that information and shove it all
 into a database.  Problem is, if someone hits reload on their browser, I
 get the same data re-inserted again.  Reload the page four times, and I
 will get four records with the same data inserted.  How can I avoid
 this?  I'd like to silently either discard the information after it's
 been inserted, or silently prevent it from being re-inserted again.

 --
 W | I haven't lost my mind; it's backed up on tape somewhere.
   +
   Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130

What I usually do is send a header redirect back to the same page. Your DB
injection should occur before any HTML output. At the end of the DB
injection simply add:

header(Location:your_php_page.php);
exit;

This will reload that page and all the $_POST data will be removed. THen
you can hit refresh all you want.

-- 
--Matthew Sims
--http://killermookie.org

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



Re: [PHP] Browser reload problem

2004-07-29 Thread Ashley M. Kirchner
On Thu, 29 Jul 2004, Skippy wrote:
ATTENTION: if you receive the PayPal data by POST be sure to redirect
using 303 See Other, which will deactivate the POST and force the
redirect to use GET. Of course, forwarding any data to the 2nd script
should be done as GET parameters.
I stuck phpinfo() in my script that PayPal calls after the
transaction, and I'm getting both _REQUEST[] as well as _POST[] values.
All the values are the same for both variable, but they're there:
_REQUEST[payment_gross] = 20.00
... several other _REQUEST variables ...
_POST[payment_gross] = 20.00
.. some more _POST variables that match the _REQUEST ones above
--
L | I haven't lost my mind; it's backed up on tape somewhere.
  +
  Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130
  IT Director / SysAdmin / WebSmith . 800.441.3873 x130
  Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
  http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Browser reload problem

2004-07-28 Thread Curt Zirzow
* Thus wrote Ashley M. Kirchner:
 
PayPal passes a ton of data back to us when someone's done 
 purchasing something.  I use some of that information and shove it all 
 into a database.  Problem is, if someone hits reload on their browser, I 
 get the same data re-inserted again.  Reload the page four times, and I 
 will get four records with the same data inserted.  How can I avoid 
 this?  I'd like to silently either discard the information after it's 
 been inserted, or silently prevent it from being re-inserted again.
 
This is what I call the BRS (Browser Reload Syndrome: the tendency
of idiodity users insisting on reloading a page unnecessarily.)

The basic solution with this problem is:
  1. generate some sort unique id on original form
  2. ensure unique id has not been entered when posted.

In your case, paypal should be returing to you some sort of
transaction Id, 'txn_id' iirc. So step 1 isn't needed.

What you need to do is before you insert the data that has been
posted to your script, is to ensure that that 'txn_id' has not been
entered already into the database.


 -- 
 W | I haven't lost my mind; it's backed up on tape somewhere.

tar xf /dev/somewhere /your/mind; :)


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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