How can I detect the site the user came from before accessing mine in PHP?
The above notes are correct, but keep in mind that the user can make his/her browser not send this information, or they can mess with this information and send false data.