PHP security in getting a parameter value -


i dont know php forgive ignorance. trying have parameter value entered in joomla admin area append string bootstrap container class change page fixed fluid layout.

i retrieving value this...

$contype = $this->params->get('contype',''); 

and setting follows...

class="container<?php echo "$contype"; ?> 

however, worried (knowing little php) if security problem since value set $contype - problem? if so, work instead...?

$contype = (int) $this->params->get('contype','0');  if($contype == "1") {  $contype = "-fluid"; } else {  $contype = ' '; } 

and echo again. necessary? there better way?

yes, work , secure.

if $contype can parameter, important escape against xss using htmlentities():

echo htmlentities($contype) 

the way did better, although costs more effort. ;-)

just remember use htmlentities in future if need escaping of many parameters , not 1 small customization. , advise, please inform php , security before continuing develop php applications (if planning to). web developer (especially php developer), should know topics "xss", "sql injection" , "csrf". :-)

[as alternative htmlentities, there htmlspecialchars, encodes less characters, see htmlentities() vs. htmlspecialchars() comparison]


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -