PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need a simple php script that verifies that a user came from my parent website and not from any other site.
If the user did not come from the parent site then they should be redirected to the home page to login.
Any php technorati out there who knows how to do this?
1. The scope of the $foobar variable means it won't be visible inside your function, so every time you call the function you'll end up redirecting the user.
2. The function doesn't strip off the protocol or the file path from the referer. You'll need to remove the http:// or https:// bit from the front and any file like index.php or users/username/ from the end.
3. Sending the refererer is optional. Some users will have come from the parent site yet HTTP_REFERER will be empty. You'll be redirecting people even though they're not meant to be redirected.
1. The scope of the $foobar variable means it won't be visible inside your function, so every time you call the function you'll end up redirecting the user.
How do I narrow the scope to make sure the function will recognize the previous url?
I have included the variable within the function {};
2. The function doesn't strip off the protocol or the file path from the referer. You'll need to remove the http:// or https:// bit from the front and any file like index.php or users/username/ from the end.
What If I need the user to come from a specific subdirectory, can I keep the "users/username/" for example?