Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Php get the last url

Posted on 2006-10-31
2
Medium Priority
?
1,354 Views
Last Modified: 2006-11-18
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
0
Comment
Question by:macbox
2 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 1500 total points
ID: 17842552
The $_SERVER['HTTP_REFERER'] variable will do that.

HOWEVER!  (and it's a big "however") that particular variable comes from the browser's HTTP request.  There's no guarantee it will exist (the browser may not send it), and there's nothing at all to keep a malicious user from faking it.

If you're just hoping to cut down on spam or something of that nature then it may do the trick.  If you're after a real security measure, this isn't it.
0
 
LVL 8

Expert Comment

by:adg080898
ID: 17846032
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.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Make the most of your online learning experience.
Starting up a Project
Loops Section Overview

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question