Jump to content

filter user input


android6011

Recommended Posts

Basically all I want are alphanumeric and basic symbols allowed. I dont want to allow tags of any sort etc. Right now I have strip_tags() and mysql_real_escape_string to keep safe from rogue user input. Any other suggestions? also, due to other problems i have magic quotes turned off in my config if that changes anything. thanks

Link to comment
https://forums.phpfreaks.com/topic/124733-filter-user-input/
Share on other sites

Maybe try this:

 

<?php
function CheckChars($input){
  $chars = array('a','b','c','d',1,2,3...); //list all acceptable characters
  $output = "";
  foreach (explode("",$input) as $char){
    if (in_array($char,$chars)) $output .= $char;
  }
  return $output;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/124733-filter-user-input/#findComment-644318
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.