Link to home
Start Free TrialLog in
Avatar of macbox
macbox

asked on

Php get the last url

Hey.

Is there a way to get the last url in php.

Example:
I pass data trough a form but i what to make shure that the form post comes from my site and not a other site.
So that the pre url can be validated
ASKER CERTIFIED SOLUTION
Avatar of VoteyDisciple
VoteyDisciple

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adg080898
adg080898

Is the user logged in? What I mean is, do you have a way to identify the user?

I am going to assume that you have some sort of database record for the user.

I suggest you have a field in your user record that stores a random string. When you generate the form page, generate a long (longer is stronger security, 32 characters is very strong) random string of characters and store that string in their user database record. Also, put a hidden field in the form with the value matching their random string.

Then, where you handle the form submission, compare the hidden field's value to the one generated when the form was displayed.

This way, the only way for the post to work is to know the value of the hidden field. This way, you can verify that the user really used your form.