Comment executer un code php quand on click dans un element html?
Bonjour,
Je suis un debutant en php puisque ça fait maintenant 2 ans que je n'ai pas encore faite du php. Bref, mon problème s'est que je veux qu'un code php s'execute lorsqu'on va cliquer dans un div html & je ne sais pas comment faire.
Lorsqu'on clique, le cookie change de valeur par le nom de la couleur.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <?php
if(empty($_COOKIE['fondo']))
{
$_COOKIE['fondo'] = 'blanco';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>Color</title>
</head>
<style type="text/css">
div
{
width:25px;
height:25px;
border:1px solid black;
}
#negro
{
background-color:black;
}
#blanco
{
background-color:white;
}
#rojo
{
background-color:red;
}
#verde
{
background-color:green;
}
#azul
{
background-color:blue;
}
#armillo
{
background-color:yellow;
}
#rosa
{
background-color:pink;
}
#gris
{
background-color:grey;
}
#naranja
{
background-color:orange;
}
#marron
{
background-color:brown;
}
#malva
{
background-color:purple;
}
</style>
<body>
<div id="blanco"></div><br>
<div id="negro"></div><br>
<div id="gris"></div><br>
<div id="rojo"></div><br>
<div id="verde"></div><br>
<div id="azul"></div><br>
<div id="malva"></div><br>
<div id="naranja"></div><br>
<div id="armillo"></div><br>
<div id="marron"></div><br>
<div id="rosa"></div><br>
<?php echo $_COOKIE['fondo'] ?>
</body>
</html> |