I am currently displaying errors on my website using this code:
<?php
$failure = strip_tags($_GET['failure']);
if($failure!=""){
echo '<div class="error">';
echo $failure;
echo '</div>';
}
?>
However, I am curious if this is safe. Is it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
while this solution would change a little bit your approach, why not have an errors.php file with this structure?
And the just send an ID as the error:
Then, include this code where you usually display your errors:
Just be sure to include errors.php in your config.php file (or whatever your main configuration’s file name is).
Why?
IMHO it is much much safer to use ints than strings in this case.