Solved

Php get the last url

Posted on 2006-10-31
2
1,349 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 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scripting vs. Programming languages 25 179
iSeries email authority 6 75
ejb wildfly example 2 29
Infrastructure development vs software development 3 62
A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.

820 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