Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do, if $_POST variables are missing?

Tags:

php

webforms

What should an application do, if a $_POST variable is missing, which is required to perform the action?

For example, imagine I have a form with an <input name="title"> and I have some page, which processes the resulting POST request. Now, what should this page do, if it gets a request, but no $_POST['title'] variable was set?

To make it clear: By "not set" I mean, that an invalid request is made, which a normal user cannot do, only somebody making a manual request to my form processing page, i.e. somebody trying to do things with my site, I don't want it to be done with.

Some possibilities:

  • Just die.
  • Print a fancy error message, like you would do, it the field were just empty.
  • Block further requests from this IP.
like image 987
NikiC Avatar asked Jul 28 '26 22:07

NikiC


1 Answers

Return to the page with the form and indicate to the user that the title has to be set.

like image 88
Geoffrey Avatar answered Jul 30 '26 20:07

Geoffrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!