0

This is code from my user registration site where data is being sent to the database. My question is if this is the correct and proper way to sanitize the data that is being sent? Also, how can I test it?

function test_input($data) { 
$data = trim($data); 
$data = stripslashes($data); 
$data = htmlspecialchars($data); 
return $data; 
}

    $email = test_input($_POST['email']);
    $firstname = test_input($_POST['firstname']);
    $lastname = test_input($_POST['lastname']);
    $user = test_input($_POST['user']);
    $pass = test_input($_POST['pass']);
    $passnew = md5($pass);
Oceans
  • 37
  • 7

1 Answers1

0

I guess This post answers all your questions. Moreover you'll get to know when to actually escape or sanitize user input.

Community
  • 1
  • 1
Asif Rahaman
  • 775
  • 6
  • 10