I would like to know if it is better, for example, to have a form where the action is set for another page, or if it is recommended to send the data to the page itself with action="<?php echo $_SERVER['PHP_SELF']?>"
.
If you have not understood, it would be more or less like this, I should use one of these two methods:
Send to same page:
<form name="login_form" action="<?php echo $_SERVER['PHP_SELF']?>" method="post" id="login_form">
And then at the top I do a check:
if(isset($_POST['logar'])):
//Código
endif;
Or should I:
Send to another page:
<form name="login_form" action="checarLogin.php" method="post" id="login_form">
And do the validation and sanitization on that particular page.
With better, I ask about safety, speed, and feasibility as well.