0

The whole idea is to create a form that makes a image in the php and then you have a confirmation page to send it as an email.

It works on my web hosting service , but it fails to work on my computer with easyPHP in mind. It does nothing , the complete image stays on the screen and does not redirect.

<?php
header( "Content-type: image/png" );

ob_start();
    if(!isset($_POST['name']) ||

        !isset($_POST['birth']) ||

        !isset($_POST['date']) ||


        !isset($_POST['asiakasnumero']))
         {

        died('We are sorry, but there appears to be a problem with the form you submitted.');       

    }


    $name = $_POST['name']; // required

    $birth = $_POST['birth']; // required

    $date = $_POST['date']; // required

    $asiakasnumero = $_POST['asiakasnumero']; // required


    $my_img = @imagecreatefrompng('card.png');


$text_colour = imagecolorallocate( $my_img, 255, 255, 255 );



imagestring( $my_img, 3, 240, 155, $name,
  $text_colour );
imagestring( $my_img, 3, 240, 215, $birth,
  $text_colour );
  imagestring( $my_img, 3, 240, 273, $date,
  $text_colour );
    imagestring( $my_img, 3, 140, 327, $asiakasnumero,
  $text_colour );





$image_path = "images/card".".png";

imagesetthickness ( $my_img, 5 );






imagepng( $my_img );
imagecolordeallocate($my_img , $text_colour );
imagepng($my_img, $image_path);
imagedestroy( $my_img );


ob_end_flush();



sleep(5);//seconds to wait..
header('HTTP/1.1 301 Moved Permanently'); //optional
header("Location: http://www.domain.com");
exit();
?>

I have tried to use .htaccess in order to redirect it but htaccess does not allow the function to do its thing. I also tried combining the image create script with the confirmation page but in vain...

Thanks!

  • Do you get any warnings? Also, why do you have output buffering? You're not doing anything with the captured output. – Halcyon Oct 01 '13 at 12:07
  • I suppose you get the following warning in your php error logs: http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12770075#12770075 – Sumurai8 Oct 01 '13 at 12:19
  • `Unknow function 'died' did u mean 'die' ?` – DarkBee Oct 01 '13 at 12:21
  • @Sumurai8 yes i do , but the issue is as it suggested to change the headers around , putting the redirect before " header( "Content-type: image/png" ); " works but it does not create the image which is an issue , but if i put it after that again it just stalls there. – CreepyMoto Oct 01 '13 at 12:43
  • @FritsvanCampen The exact warning that Sumurai8 posted is in the error logs. Output buffering fixed an issue i had before but apparently is not there anymore, it was there to do the whole make image thing and then stop, according to my mighty googling skills. – CreepyMoto Oct 01 '13 at 12:45
  • @CreepyMoto I suppose you want to write the image to a file. It shouldn't print anything to the screen. Find out what line 'starts' the output. Lookup the documentation for that function to find out what you should do with that output, or if there isn't a more appropriate function to use. The warning I linked has some more debugging options. – Sumurai8 Oct 01 '13 at 13:08

0 Answers0