How to protect HTML form from blank submission

前端 未结 5 1963
梦毁少年i
梦毁少年i 2021-01-15 15:59

Basically I\'m using this tutorial: HTML FORM

Everything is working as it should but one flow I\'ve found is that everyone can see the URL for your

5条回答
  •  不思量自难忘°
    2021-01-15 16:16

    Say you have the following form;

    In this, instead of a submit type input, I have used a button. This means, something needs to happen before the page will submit, so, for example;

    
    

    The JavaScript function here will only call the submit on the form when the inputs are not empty

    In terms of stopping someone from accessing this without permission;

    Using die in this, will terminate execution of the script any further, you can also use exit and both allow you have have a "termination message" attached to them as part of the stoppage process

    $_REQUEST isn't the safest of options, but it permits you to use GET or POST methods from forms to be able to retrieve and use data

提交回复
热议问题