Prevent access to php file

by 7 replies
8
I have a form behind user authentication that submits to a php file. I am worried people will stop paying for my service yet still send values (via the url or creation of their own form) to the php file directly.

How can I prevent this?
#programming #access #file #php #prevent
  • You can't put php file behind authentication?

    You could check where people come in to the script, check referee. If it comes from your site or ip, then allow execution.

    But this depends totally what kind of configuration you have on your system at the moment...
    • [1] reply
    • If you're using normal Linux authentication and the file is in a secured directory taking someone out of the authentication file would disallow them from using any files in that directory.

      If you wanted another method you could set a cookie when they login and then check for that cookie at the top of every page.
      • [1] reply
  • please use an htaccess to hide php files!
  • like mmstud said, as long as the first server is always the server that sends requests to your PHP file...then you could implement IP checking code at the top of the PHP file and only accept requests that come from the IP address of your first server. That way if a user manually tries to access your PHP script, your code can just reject the request since its coming from an IP that is not from your main server...
    • [1] reply
    • I may be wrong here but if they're no longer a member then they should be listed as such, and so no matter how they try to login, the site shouldn't let them in.
  • lock cookies to session id for that user so when cookie expires so does session and thus they must login again to access said form.

Next Topics on Trending Feed

  • 8

    I have a form behind user authentication that submits to a php file. I am worried people will stop paying for my service yet still send values (via the url or creation of their own form) to the php file directly. How can I prevent this?