je suis en train de débuter en php en créant un générateur de texte sur image avec l'aide du php et de GD.
Je sollicite votre aide car je bloque à un étape.
Voici déjà mon code :
Code : Tout sélectionner
<?php
if (isset($_GET['Position1']) && isset($_GET['Position2']) && isset($_GET['Position3'])
&& isset($_GET['Position4']) && isset($_GET['Position5']) && isset($_GET['Position6'])
&& isset($_GET['Position7']) && isset($_GET['Position8']) && isset($_GET['Position9'])
&& isset($_GET['Position10']) && isset($_GET['Position11'])) {
header ("Content-type: image/png");
$image = imagecreatefrompng("442losange.png");
imagestring($image, 3, 25, 199, $_GET['Position1'], $blanc);
imagestring($image, 3, 130, 357, $_GET['Position2'], $blanc);
imagestring($image, 3, 130, 55, $_GET['Position3'], $blanc);
imagestring($image, 3, 130, 156, $_GET['Position4'], $blanc);
imagestring($image, 3, 130, 255, $_GET['Position5'], $blanc);
imagestring($image, 3, 232, 206, $_GET['Position6'], $blanc);
imagestring($image, 3, 317, 103, $_GET['Position7'], $blanc);
imagestring($image, 3, 317, 303, $_GET['Position8'], $blanc);
imagestring($image, 3, 511, 256, $_GET['Position9'], $blanc);
imagestring($image, 3, 406, 206, $_GET['Position10'], $blanc);
imagestring($image, 3, 511, 156, $_GET['Position11'], $blanc);
$couleur_fond = ImageColorAllocate ($image, 255, 0, 0);
imagepng ($image, 'mon_image.png');
}
else {
echo 'Les variables du formulaire ne sont pas déclarées.';
}
?> Je souhaiterais créer des images tout en gardant les anciennes déjà crées.
Mais tout le problème viens du fait que l'image crée à toujours le même nom ('mon_image.png'). Donc la dernière image crée écrase la précédente.
Je suppose donc que je doit mettre une portion de code qui déterminerais un nom aléatoire à chaque image crée. Mais j'ai beau chercher, je n'arrive pas a trouver de méthode.
J'espère que vous pourrez m'aider.
Je vous remercie d'avance