J
J
Jony13372015-10-16 16:25:42
PHP
Jony1337, 2015-10-16 16:25:42

Text over image?

There is a script that text on top of the image.
The text that a person enters on the index.php page

<div class="rtext2">Enter you names:</div>
     
         <form method="POST" action="load.php?id=<? echo $id;?>" style="padding-top: 5px;">
         <input type="text" name="name" placeholder="Ex. your names" style="width: 310px; height: 51px; font-size: 18px; padding-left: 8px; border: 4px solid #77B200;">
       
     <input type="submit" style="height: 70px; width: 250px; font-size: 15px; border: none; margin-top: 15px; background: -3px -3px url ' input type="submit" class="button_find" value=Afla! ' no-repeat;" value="">
     </form>

Here is the code for the Text on top of the image:
<?php 
function writeTextOnImage($filename, $text)  
{   
    $size_img = getimagesize($filename);  
    if ($size_img[2]==2)       $src_img = imagecreatefromjpeg($filename);  
    else if ($size_img[2]==1)  $src_img = imagecreatefromgif($filename);  
    else if ($size_img[2]==3)  $src_img = imagecreatefrompng($filename);    
    // устанавливаем цвет нашей надписи и прозрачность (тут он будет синий и полностью прозрачный)
    $color = imagecolorallocatealpha($src_img, 255, 128, 64, 0);  
    $font_file = "font.ttf";  // шрифт, которым пишем надпись (будьте внимательны с путем к шрифту)
    $img_x = imagesx($src_img); 
    $img_y = imagesy($src_img);     
    $height_font = 30; // размер шрифта 
    $angle = 0;  // наклон надписи
  $iddmg = $_GET['idd'];
     
    // Запись текста поверх изображения  
    $box = imagettftext($src_img, $height_font, $angle, $img_x - 655, $img_y - 285, $color, $font_file, $text); 
 
    // Вывод изображения в браузер  
    if ($size_img[2]==2)  
    {  
        header ("Content-type: image/jpeg");  
        imagejpeg($src_img, 'images/'.$iddmg.'.jpg');
        imagejpeg($src_img);		
    }  
    else if ($size_img[2]==1)  
    {  
        header ("Content-type: image/gif");  
        imagegif($src_img);  
    }  
    else if ($size_img[2]==3)  
    {  
        header ("Content-type: image/png");  
        imagepng($src_img);
        imagejpeg($src_img, 'images/'.$iddmg.'.png');		
    }  
    return true;  
} 
// использование 
$name = $_GET['name'];
$ran_dom = rand (1 , 10);
$img = "img/".$ran_dom.".png"; // путь к изображению
writeTextOnImage($img, "$name");

the photo is displayed to the user on the load.php page
question:
If I enter two forms of text input, how to display two different texts that were entered on the index.php page

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
titronfan, 2015-10-16
@titronfan

In somehow in a mess it is written. And it's not clear - if the writeTextOnImage function works - what's the point of placing it here? Those. I mean - you need to write immediately closer to the point.
All I understood from this is that you will have 2 forms. What for? Two inputs won't work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question