0

Hey, htmlentities doesn't work in this code of mine, someone know why?
Check line 11-14
Thanks.

<html>
<head>
<title> Welcome <?php echo $_GET['name']; ?> </title>
</head>
<body bgcolor="<?php echo $_GET["favcolor"]; ?>"?

<h1> Welcome <?php echo $_GET['name']; ?> </h1> <br />

<?php 

foreach ($_GET as $key => $verdi) {
$verdi = htmlentities($verdi);
$key = htmlentities($key);
}
echo "You live in ";
echo $_GET['country'];
echo ", ";
echo $_GET['city'];
echo " And your favorite color is "; 
switch ( $_GET['favcolor'] ) {

case "#ff0000";
$favcolortext="Red";
break;

case "#8bcdff";
$favcolortext="Blue";
break;


case "#fff600";
$favcolortext="Yellow";
break;

case "#0cff00";
$favcolortext="Green";
break;

case "#a200ff";
$favcolortext="Purple";
break;

case "#6000ff";
$favcolortext="Violet";
break;

case "#ff68e1";
$favcolortext="Pink";
break;

case "#fbfadd";
$favcolortext="Vanillia";
break;

case "#730404";
$favcolortext="Dark Red";
break;

case "#10057a";
$favcolortext="Dark Blue";
break;

case "#157a05";
$favcolortext="Dark Green";
break;

case "#17bb9e";
$favcolortext="Cyan";
break;

case "#40f0fb";
$favcolortext="Baby Blue";
break;

}

echo "$favcolortext.";

?>
</body>
</html>

Anyone wants to add me to msn? mzm_mc@hotmail.com
good coder or not, IDC. Just need some coding buddies =)

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Muazam
0

You are just setting the value to a variable.

You should do something like this:

foreach( $_GET as $key => $val ) {
  $_GET[$key] = htmlentities( $val );
}
0

Thanks alot, it helped.
Could you explain me one more thing, my books is telling me to do it like this:

foreach ($_GET as $key => $val) {
$val = htmlentities($val);
if ( $key <> "name")

And it says " So on..." the books doesn't tell me more about this.
My question is what is this "<>" function called and what does it do?
or what should I search on google to get more info about this.

Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.