Validation using a random number problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bobby9101
Forum Commoner
Posts: 28
Joined: Thu Apr 27, 2006 1:18 pm

Validation using a random number problem

Post by bobby9101 »

Hi.
I am building a simple payment script.
The user goes to a form (say form.php) he enters the data in the form, and then submits it.
He is then sent to: payment.php, which has a paypal payment button. (the return URL is set to domain.com/form.php?randnumber=99 (where 99 is a random number generated in form.php)
after completing payment, the visitor is sent to: domain.com/form.php?randnumber=99 (where 99 is a random number generated in form.php)
The only problem si that when he returns, the rand number gets re randomized. Any way around this?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Use sessions to store the random value.

Out of curiosity, why exactly are you doing this?
bobby9101
Forum Commoner
Posts: 28
Joined: Thu Apr 27, 2006 1:18 pm

Post by bobby9101 »

Lemme explain a little better. (bear with me I am just starting PHP)

I had:
A visitor visits a form, submits the form and then goes to paypal. After paypal he gets redirected back to a thank you page and the data from cookies is entered into a database.
Well the user (if smart) would just submit the form and manually type in the thank you page.

So I decided to make the user come back to the same page except with a random number appended to the URL, so that he couldn't bypass the paypal part.
If there is a better way, let me know.
Post Reply