<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://localhost/dpe/css/template.css" type="text/css" />
</head>
<body>
<div class="php">
<form action="teste3.php" method="post">
<input type="text" name="dpe" />
<input type="submit" value="valider" />
</form>
<img src="teste3.php<?php if (empty($_POST['dpe'])) echo '?dpe='.$_POST['dpe']; ?>" />
<br />clique <a href='resultat.jpg'>ici</a> pour telecharger l'image.
</div>
</body>
</html>
Pour le PHP:
<?php
if($_GET['dpe']>=0 && $_GET['dpe']<=50)
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/1.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 76, $_GET['dpe'], $text_color);
header("Content-type: image/jpeg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else if($_GET['dpe']>=51 && $_GET['dpe']<=90)
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/2.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 122, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else if($_GET['dpe']>=91 && $_GET['dpe']<=150)
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/3.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 172, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else if($_GET['dpe']>=151 && $_GET['dpe']<=230)
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/4.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 216, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else if($_GET['dpe']>=231 && $_GET['dpe']<=330)
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/5.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 262, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else if($_GET['dpe']>=331 && $_GET['dpe']<=450)
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/6.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 306, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else
{
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/7.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 355, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://localhost/dpe/css/template.css" type="text/css" />
</head>
<body>
<div class="php">
<form action="" method="get">
<input type="text" name="dpe" />
<input type="submit" value="valider" />
</form>
<?php
if (!empty($_GET['dpe'])) {
include 'teste3.php';
ech
echo '<img src="resultat.jpg" /><br />clique <a href="resultat.jpg">ici</a> pour telecharger l\'image.';
}
?>
</div>
</body>
</html>
le code qui génère l'image
<?php
if($_GET['dpe']>=0 && $_GET['dpe']<=50) {
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/1.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 76, $_GET['dpe'], $text_color);
//header("Content-type: image/jpeg");
////imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
elseif($_GET['dpe']>=51 && $_GET['dpe']<=90){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/2.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 122, $_GET['dpe'], $text_color);
//header("Content-type: image/jpg");
//imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
elseif($_GET['dpe']>=91 && $_GET['dpe']<=150){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/3.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 172, $_GET['dpe'], $text_color);
//header("Content-type: image/jpg");
//imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
elseif($_GET['dpe']>=151 && $_GET['dpe']<=230){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/4.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 216, $_GET['dpe'], $text_color);
//header("Content-type: image/jpg");
//imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else if($_GET['dpe']>=231 && $_GET['dpe']<=330){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/5.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 262, $_GET['dpe'], $text_color);
//header("Content-type: image/jpg");
//imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
elseif($_GET['dpe']>=331 && $_GET['dpe']<=450){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/6.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 306, $_GET['dpe'], $text_color);
//header("Content-type: image/jpg");
//imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
else {
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/7.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 355, $_GET['dpe'], $text_color);
//header("Content-type: image/jpg");
//imagejpeg ($im);
imagejpeg ($im, 'resultat.jpg', 100);
imagedestroy($im);
}
?>
@+<?php
if($_GET['dpe']>=0 && $_GET['dpe']<=50) {
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/1.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 76, $_GET['dpe'], $text_color);
header("Content-type: image/jpeg");
imagejpeg ($im);
imagedestroy($im);
}
elseif($_GET['dpe']>=51 && $_GET['dpe']<=90){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/2.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 122, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagedestroy($im);
}
elseif($_GET['dpe']>=91 && $_GET['dpe']<=150){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/3.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 172, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagedestroy($im);
}
elseif($_GET['dpe']>=151 && $_GET['dpe']<=230){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/4.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 216, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagedestroy($im);
}
else if($_GET['dpe']>=231 && $_GET['dpe']<=330){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/5.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 262, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagedestroy($im);
}
elseif($_GET['dpe']>=331 && $_GET['dpe']<=450){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/6.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 306, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagedestroy($im);
}
else {
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/7.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 355, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
imagedestroy($im);
}
?>
et
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://localhost/dpe/css/template.css" type="text/css" />
</head>
<body>
<div class="php">
<form action="" method="get">
<input type="text" name="dpe" />
<input type="submit" value="valider" />
</form>
<?php
if (!empty($_GET['dpe'])) {
include 'teste3.php';
echo '<img src="teste3.php?dpe=$_GET['dpe']" />';
}
?>
</div>
</body>
</html>
et la par contre il me met une erreur:<?php
if($_GET['dpe']>=0 && $_GET['dpe']<=50) {
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/1.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 76, $_GET['dpe'], $text_color);
header("Content-type: image/jpeg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
elseif($_GET['dpe']>=51 && $_GET['dpe']<=90){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/2.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 122, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
elseif($_GET['dpe']>=91 && $_GET['dpe']<=150){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/3.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 172, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
elseif($_GET['dpe']>=151 && $_GET['dpe']<=230){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/4.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 216, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
else if($_GET['dpe']>=231 && $_GET['dpe']<=330){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/5.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 262, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
elseif($_GET['dpe']>=331 && $_GET['dpe']<=450){
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/6.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 306, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
else {
$font = 18;
$width = ImageFontWidth($font) * strlen($_GET['dpe']);
$height = ImageFontHeight($font);
$fichier="images/7.jpg";
$im = ImageCreateFromJpeg ($fichier);
$text_color = imagecolorallocate ($im, 255,255,255);
imagestring ($im, $font, 398, 355, $_GET['dpe'], $text_color);
header("Content-type: image/jpg");
imagejpeg ($im);
echo "<img src=\"teste3.php?dpe={$_GET['dpe']}\" />";
imagedestroy($im);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://localhost/dpe/css/template.css" type="text/css" />
</head>
<body>
<div class="php">
<form action="" method="get">
<input type="text" name="dpe" />
<input type="submit" value="valider" />
</form>
<?php
if (!empty($_GET['dpe'])) {
include 'teste3.php';
}
?>
</div>
</body>
</html>
Merci encore pour votre aide