So is that better to use $code
when validating password inputs or i just have to use $_POST['code']
?
When exactly should the secure_input
function be used when it comes to security?
Is there a better way to perform the below password validation?
More on php form security here
<?php
function secure_input($data) {
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$code = secure_input($_POST['code']);
if($code == "ok") echo 'success';
?>
<form method="post" action="">
Name: <input type="text" name="code">
<input type="submit">
</form>