February 27, 200917 yr How do i get the location that the data is coming from? I have data coming from file1.html that i want sending to process.php, but process.php needs to know the name of file1 in order to create a variable called file1 Basically how do i detect the referring url? The only way i know of is $_SERVER["HTTP_REFERER"]; but i've been told that shouldn't be used. (would it even work for post data?)
February 27, 200917 yr HTTP is a stateless protocol. It can provide you with no knowledge of inter-request communications. The best that can happen is a browser by its choice sends you the referring URL (accessed in the way you mention using $_SERVER), or you are fortunate to be able to use sessions (e.g. with a session tracking cookie on the client) to be able to track requests from the same client. Neither are 100% reliable, though more frequently than not they both do work. But here I think your problem is much simpler: why do you not include data on which page the request is coming from in the URL to process.php itself? For example, "process.php?from=file1". Or if file1.html is an HTML form, use a hidden form field - like <input type="hidden" name="from" value="file1" />. That's the most robust method.
February 27, 200917 yr Author Hmmm, makes sense. Thanks, looks like i was making a mountain out of a mole hill, as per usual I'll post back if i have a problem, but i don't think i will, thanks.
Create an account or sign in to comment