Jump to content

Prevent direct access to action= file


Tomballa

Recommended Posts

Alright, I have a script that submits user inputed data to a mysql database, but I don't want the file called upon in the form to be able to be put in the url and gone to.Example:

<form action='insert.php' method='post'>

The insert.php file adds a new row to the database and fills in the cells with $_POST info. If I go to www.mysite.com/insert.php then a new row is inserted but no info is put in (because they didn't fill out a form).How would I go about making sure that people can only access insert.php from the page that the form is on?

Link to comment
Share on other sites

You can just do an if(!isset($_POST['variable']) || !isset($_POST['variable2'])){echo "message saying that you need to go to this page through the form";}else{insert into db etc..}:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...