如何用PHP在图片上输入HTML输入文本

Got this HTML code:

<input class="text" name="Chipnummer" type="text" value="adding text" />

I want to save it on my picture like this

my php:

$text['adding text'];

imagefttext($image, 60, 0, 650, 270, $red, 'verdana.ttf',['adding text']);

$filename       = 'stamtavle1.png';

but it is not working ??

i want to save the picture with the $hvalpe_data['navn1'] as name.

$filename = $hvalpe_data['navn1'].png;

It is getting a file instead of a png

I really need you help.

<div class="image">
<img src="image/stamtavle.png" alt="" style=" width:1200;">

     <h2><?=$hvalpe_data['navn1'];?></h2> 
     <h4><input class="text" name="Chipnummer" type="text" value="Chipnummer"></h4>
     <text><input class="text" name="Stambogsnummer" type="text" value="Stambogsnummer"></text>
     <text1><?=$hvalpe_data['hvalp_farve'];?><text1>
     <text2><?=$hvalpe_data['firstname'] . ' ' . $hvalpe_data['lastname'];?><text2>
     <text3><?=$hvalpe_data['adresse'];?></text3>
$POST['chpinummer'];

$hvalpe_data['navn1'];
$hvalpe_data['firstname'] . ' ' . $hvalpe_data['lastname'];
$hvalpe_data['adresse'];

$image = imagecreatefrompng('stamtavle.png');
imagealphablending($image, true);

$black  = imagecolorallocate($image, 150,0, 0);

// imagefttext("Image", "Font Size", "Rotate Text", "Left Position", "Top Position", "Font Color", "Font Name", "Text To Print");

imagefttext($image, 40, 0, 850, 390, $$black, 'verdana.ttf', $POST['chpinummer']);
imagefttext($image, 40, 0, 850, 390, $$black, 'verdana.ttf', $hvalpe_data['firstname'] . ' ' . $hvalpe_data['lastname']);   
imagefttext($image, 40, 0, 850, 440, $$black, 'verdana.ttf', $hvalpe_data['adresse']);
imagefttext($image, 40, 0, 850, 490, $$black, 'verdana.ttf', $hvalpe_data['post']);

You have several syntactical issues with your PHP code.

First, the PHP super global for retrieving form data should be either $_POST or $_GET, depending on your <form method="post"> if the method attribute is missing or is set to method="get" you will need to use $_GET.

Second, PHP is case-sensitive when accessing array indexes, so since you are using <input name="Chpinummer"> your PHP needs to correspond with the form field name casing. So you would use $_POST['Chpinummer'] to retrieve the submitted value, provided the form method is indeed method="post".

Third, using $$ with a PHP variable will cause the value to return a reference to a variable variable. Since you are declaring the imagecolorallocate color as $black you need to use $black not $$black.

Lastly, there is no way to know what values are declared as $hvalpe_data, since you did not provide an example in your question. So for brevity I have removed the references to them to focus only on the specific issue.

$image = imagecreatefrompng('stamtavle.png');
imagealphablending($image, true);

$black = imagecolorallocate($image, 150, 0, 0);

imagefttext($image, 40, 0, 850, 390, $black, 'verdana.ttf', $_POST['Chpinummer']);

Furthermore, it is best-practice to specify the full (absolute) path to reference file resources, ie: /full/path/to/file. If your file resources are within the same directory as your PHP script. ie: /var/www/public/script.php and /var/www/public/stamtavle.png you should use __DIR__ . '/stamtavle.png'. For more details see __DIR__

$image = imagecreatefrompng(__DIR__ . '/stamtavle.png');
imagealphablending($image, true);

$black = imagecolorallocate($image, 150, 0, 0);

imagefttext($image, 40, 0, 850, 390, $black, __DIR__ . '/verdana.ttf', $_POST['Chpinummer']);