Send data to another page or send it to another page?

2

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.

    
asked by anonymous 04.04.2017 / 20:04

1 answer

2

Sending to another script tends to make your code more organized, making it more feasible for future edits.

In terms of speed the less redirects will be faster, but just one more redirection will not change much, depending a lot on what you are trying to do.

And in the matter of security in my opinion this kind of thing does not influence.

    
04.04.2017 / 20:15