0

Hello am a newbie in php, so i dont have much knowledge about that. I am trying to add text over image with form method but that doesnt works Here are the codes

In form-add-text.php

 <form id="action-meme" action="mysite.com/image-process.php/">

<input name="cp" id="inputcpname" type="text" >
<input type="submit" >
</form>

Here is the code in image-process.php

  <?php
  //Set the Content Type
  header('Content-type: image/jpeg');

  // Create Image From Existing File
 $jpg_image = imagecreatefromjpeg('http://i.imgur.com/xxxYpW.jpg');

  // Allocate A Color For The Text
   $white = imagecolorallocate($jpg_image, 255, 255, 255);

  // Set Path to Font File
 $font_path = 'http://fonts.googleapis.com/css?family=Gabriela';

 // Set Text to Be Printed On Image
 $text = $_POST["cp"];

 // Print Text On Image
  imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);

 // Send Image to Browser
 imagejpeg($jpg_image);

 // Clear Memory
 imagedestroy($jpg_image);
?>

BUt if i replace "$_POST["cp"]" with some text it works well

I am unable to figure out my work

2 Answers 2

3

add method="post" in form

 <form id="action-meme" action="mysite.com/image-process.php/" method="post" >

<input name="cp" id="inputcpname" type="text" >
<input type="submit" >
 </form>
Sign up to request clarification or add additional context in comments.

Comments

1

Try adding method to the form

 <form id="action-meme" action="mysite.com/image-process.php/" method="post">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.