its simple, you just need to filter the input to save your script from SQL injection, if you want to create this functionality on one page, then you should use propper conditions to check incoming messages,
php FILTER_SANITIZE_(check string,password,number,or other things) very convenient this way
jugnu source share