AJAX Security Issue -


i'm new ajax. , saw tutorial how retrieve database result using ajax http://www.w3schools.com/php/php_ajax_database.asp

source code url :

<script> function showuser(str) { if (str=="")   {   document.getelementbyid("txthint").innerhtml="";   return;   } if (window.xmlhttprequest)   {// code ie7+, firefox, chrome, opera, safari   xmlhttp=new xmlhttprequest();   } else   {// code ie6, ie5   xmlhttp=new activexobject("microsoft.xmlhttp");   } xmlhttp.onreadystatechange=function()   {   if (xmlhttp.readystate==4 && xmlhttp.status==200)     {     document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext;     }   } xmlhttp.open("get","getuser.php?q="+str,true); xmlhttp.send(); } 

is code secure enough? other concerns need check other server side validation security? best practice regarding security apply code?

thanks , i'm sorry dumb question. t_t

the 'secure enough' part depends on over server side. @ client, there missing part here "str" value encoded proper url value , hence cause problems.

you should @ least use encodeuricomponent (or escape) method when concatenating url parts.

xmlhttp.open("get","getuser.php?q="+encodeuricomponent(str),true); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -