I get input from user through a form and then process.
For example,
Method 1:
if $_POST[\\'submit\\']{
$title = $_POST[\\'title\\'];
$message = $_POST[\\'message\\'];
send_message($title, $message);
}
Now
function send_message($title, $message){
$t= secure($title);
$m = secure($message);
---
--
}
Method 2:
if $_POST[\\'submit\\']{
$title = secure($_POST[\\'title\\']);
$message = secure($_POST[\\'message\\']);
send_message($title, $message);
}
function send_message($title, $message){
//No need to secure here as its already done.
}
Please note that i did not secure the input, i sent the input as the user submitted it. I will secure it in the send_message function before i insert to database.
So my question is that, is there any security risk by passing the inputs in a function as above?
Should i secure the inputs before i call the send_message function?
Which of the method is better?