halben Posted September 17, 2013 Share Posted September 17, 2013 Hello Guys/Gals, Can someone please tell me how safe this sanitation is? $username = filter_var($_POST['user_name'], FILTER_SANITIZE_STRING); Thanks, Halben Quote Link to comment https://forums.phpfreaks.com/topic/282224-sanitizing-strings-question/ Share on other sites More sharing options...
AbraCadaver Posted September 17, 2013 Share Posted September 17, 2013 Depends upon what you need. What are you hoping that will do? Make it safe for what? Quote Link to comment https://forums.phpfreaks.com/topic/282224-sanitizing-strings-question/#findComment-1449905 Share on other sites More sharing options...
halben Posted September 17, 2013 Author Share Posted September 17, 2013 I'm doing something like this: $user_email_data = trim(strip_tags(stripslashes($_POST['user_email']))); // Now use PHP to check for validation if (filter_var($user_email_data, FILTER_VALIDATE_EMAIL)) { ..... How safe is that? Quote Link to comment https://forums.phpfreaks.com/topic/282224-sanitizing-strings-question/#findComment-1449921 Share on other sites More sharing options...
AbraCadaver Posted September 17, 2013 Share Posted September 17, 2013 (edited) I'm doing something like this: $user_email_data = trim(strip_tags(stripslashes($_POST['user_email']))); // Now use PHP to check for validation if (filter_var($user_email_data, FILTER_VALIDATE_EMAIL)) { ..... How safe is that? Validate and sanitize filters are different. Sanitize will change it to make it "safe" and validate tells you whether it is valid or not. Edited September 17, 2013 by AbraCadaver Quote Link to comment https://forums.phpfreaks.com/topic/282224-sanitizing-strings-question/#findComment-1449923 Share on other sites More sharing options...
halben Posted September 17, 2013 Author Share Posted September 17, 2013 I think I figured it out. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/282224-sanitizing-strings-question/#findComment-1449925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.