1

I have an array that already contains all it's values in alphabetical order:

  Alligator
  Alpha
  Bear
  Bees
  Banana
  Cat
  Cougar

up to Z Now I want hat when I get Input from my Html file for Example I write "Name" in the html input box then it should get split that into alphabet and give output like

N A M E  
N A M E
A N A V
U N T I
G O U L
H Y R
T I E
Y N
  G     

In This way I must get Result with a image on background for image and text I used my Php code below but tried many time not getting the result the result should be in same manner in which I have shown My html code is:name.html

 <html>
 <head lang="en">
 <meta charset="UTF-8">
 <title></title>
 </head>
 <body>
 <form action="result.php" method="get">
 <input type="text" id="name" name="myname" placeholder="E.g: abc">
 <input type="submit" value="Submit">
 </form>
 </body>
 </html>

My php code is: result.php

<?php

header('Content-type: image/jpeg');
$jpg_image = imagecreatefromjpeg('Desert.jpg');
$white = imagecolorallocate($jpg_image, 73, 41, 236);
$font_path = 'OpenSans-Italic.TTF';
$text = $_GET['name'] ;
imagettftext($jpg_image, 25, 0, 75, 50, $white, $font_path, $text);
imagejpeg($jpg_image);
imagedestroy($jpg_image);
?>
John Conde
  • 217,595
  • 99
  • 455
  • 496
learner
  • 307
  • 1
  • 2
  • 12
  • possible duplicate of [Create ArrayList (ArrayList) from array (T\[\])](http://stackoverflow.com/questions/157944/create-arraylist-arraylistt-from-array-t) – learner Apr 24 '15 at 12:12

1 Answers1

0

I was able to lay text on top of the image. I think this is what you're trying to accomplish, yes? Please also visit this sample site (if you have not done so already) http://www.phpforkids.com/php/php-gd-library-adding-text-writing.php

With header set to "image/jpeg" it renders an image in the browser but will not print text.

If your input name is 'myname' then the _GET param in results.php needs to match. Prevent any unwanted spaces using trim the variable.

$text = trim($_GET['myname']);

If it is a public-facing website, sanitize the input. http://php.net/manual/en/function.filter-var.php

Adam T
  • 675
  • 8
  • 22
  • sorry but that was not the correct answer for my question I'm not getting any error I just cannot add html contents in my php file any want to show example like answer when we put any value in the previous html file and get the value like as shown in the question – learner Apr 14 '15 at 13:39
  • Ok I see now, I will edit answer soon. Where are you looking to add the html? I am not sure it can be done with that particular header being set. – Adam T Apr 14 '15 at 13:48
  • what about the php file which is not showing html contents in them – learner Apr 14 '15 at 13:50