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
https://forums.phpfreaks.com/topic/287344-multiple-_get-not-working/
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');
}
    ?> 

 

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);
?>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.