hi every one I'm new and it really interesting what's happening here !!
Well I'm a beginner in PHP , the problem is that when i use print_r($message) or echo in the same page where I call header I got this message
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\xampp\crypter.php:13) in C:\xampp\htdocs\xampp\crypter.php on line 85
that is my code
<?php
$length = 5; // length of the string
$alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; // possible character to use
$nb_characters = strlen($alphabet); // number of character
// the string that i want to randomize
$string = '';
for($i = 0; $i < $length; ++$i)
{
$string .= $alphabet[mt_rand(0, $nb_characters-1)];
}
print($string); // here i want to printout my strin
// we use the length of the string
$str_length = strlen($string);
// Creating the image zone whit the size specified
$image = imagecreatetruecolor(30 * $str_length, 50);
// Creating the background
for($x = 0; $x < imagesx($image); ++$x)
{
for($y = 0; $y < imagesy($image); ++$y)
{
if (mt_rand(1,5) == 4)
{
$vred = mt_rand(100, 150);
$vgreen = mt_rand(100, 150);
$vblue = mt_rand(100, 150);
}
else
{
$vred = 255;
$vgreen = 255;
$vblue = 255;
}
// Allocating background color
$color = imagecolorallocate($image, $vred, $vgreen, $vblue);
// shohws the pixel
imagesetpixel($image, $x, $y, $color);
// delete the color
imagecolordeallocate($image, $color);
}
}
// Creating border
$vred = mt_rand(1, 80);
$vgreen = mt_rand(81, 160);
$vblue = mt_rand(161, 240);
// Allocating color
$color = imagecolorallocate($image, $vred, $vgreen, $vblue);
// Tracing the border
imagerectangle($image, 0, 0, imagesx($image)-1 , imagesy($image)-1, $color);
//deleting the color allocated
imagecolordeallocate($image, $color);
// Creating the text
for($i = 0; $i < $str_length; ++$i)
{
$vred = mt_rand(1, 80);
$vgreen = mt_rand(81, 160);
$vblue = mt_rand(161, 240);
$size = mt_rand(20, 30);
$angle = mt_rand(-10, 10);
$x = 13 + (20 * $i);
$y = mt_rand(30, imagesy($image) - 10);
$color = imagecolorallocate($image, $vred, $vgreen, $vblue);
$font = 'AnkeCalligraph.TTF';
// Drawing the text
imagettftext($image, $size, $angle, $x, $y, $color, $font, $string[$i]);
// deleting the color
imagecolordeallocate($image, $color);
}
// creatin the image
header("Content-type: image/png");
imagepng($image);
?>