Jump to content

Multiple $_GET not working ?


Glenskie

Recommended Posts

I am trying to set variables with $_GET from the url...

 

caption.php?image=53348b3068f36.jpg&topcaption=sdfas&bottomcaption=asdfadf

 if (isset($_GET['image'])){
            $picture = $_GET['image'];
            $topcaption = $_GET['topcaption'];
            $bottomcaption = $_GET['bottomcaption'];

 

Link to comment
Share on other sites


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');




      //Set the Content Type
      header('Content-type: image/jpeg');
       if (isset($_GET['image'])){
            $picture = $_GET['image'];
            $topcaption = $_GET['topcaption'];
            $bottomcaption = $_GET['bottomcaption'];


      // Create Image From Existing File
      $jpg_image = imagecreatefromjpeg("../useruploadedphotos/$picture");


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


      // Set Path to Font File
      $font_path = 'fonts/Timeless-Bold.ttf';


      // Set Text to Be Printed On Image
      $text = "$topcaption";


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


      imagejpeg($jpg_image, "../photos/$picture");


      imagejpeg($jpg_image, "../useruploadedphotos/$picture");


       imagejpeg($jpg_image);
      // Clear Memory
      imagedestroy($jpg_image);


// header("location: success.php");
}
else{
      die('eror');
}
    ?> 
Link to comment
Share on other sites

 

ginerjm: I am not familiar with the graphics functions of php.  I don't see any output in the above script.  Where do you actually send something out to the client?

 

I am not familiar with the graphics functions of php.  I don't see any output in the above script.  Where do you actually send something out to the client?

 

 

This needs fix (error): - echo your errors as well for debugging.

die('eror');

And add this to the top of your page

<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
?>
Edited by Ansego
Link to comment
Share on other sites

at a minimum, you need to move the header('Content-type: image/jpeg'); statement down so that it is right above the        imagejpeg($jpg_image); line. by outputting the header() first, any php or application error messages are treated as part of the binary image data.

 

i also notice that you are saving the image to two different files. if your intent is to save the image, why are you outputting it to the browser using the header(); and imagejpeg($jpg_image); statements?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.