MyBB Community Forums

Full Version: php script help :)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
OK thanks Smile


Now; how do i make it so something like this happens;

1) I type in my browser www.mysite.com/script.php?text=mytexthere

and "mytexthere" is printed on my png image?

I know it will be something like:
$text = $_get......

and then

imagestring($image, 2, 140, 15,  $text,

anyone?
hello?
I guess I can do all your work for you. Here is a simple captcha type bit. Put the code below in its own php file and then use the filename of the script as the image source

<img src="thisscript.php?text=mystring">

<?php
$circles=5;
$width=300;
$height=40;
$font=3;

$randno=rand(0,sizeof($text)-1);

$fontwidth = ImageFontWidth($font) * strlen($string);
$fontheight = ImageFontHeight($font);

$im = imagecreate ($width,$height);
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, rand(0,100), rand(0,100),rand(0,100)); // Random Text

for ($i=1;$i<=$circles;$i++) {
$randomcolor = imagecolorallocate ($im , rand(100,255),rand(100,255),rand(100,255));
imagerectangle($im,rand(0,$width-10),rand(0,$height-3),rand(20,70),rand(20,70),$randomcolor);
}

imagerectangle($im,0,0,$width-1,$height-1,$text_color);
imagestring ($im, $font, rand(3, $width-$fontwidth-3),rand(2,$height-$fontheight-3),  $text, $text_color);
//header ("Content-type: image/jpeg");
imagejpeg ($im);
imagedestroy($im);
?>


Needs GD or ImageMagick to work though
ok that is strange:

http://gfx-core.com/text.php?text=blahblah

I just want to know the syntax for making the text put in the URL (?text=yourtexthere) so i can use it in the imagestring.
do you have GD or imagemagic?
GD Smile
Are you sure its activated? Or maybe its the encoding thats messed. One of the two.
GD is working fine as i use it for some of my other scripts, i just want to know the syntax for the get function Smile
$text = $_GET['text'];
// Then use the $text variable in your image creation function.
Thanks!

One quick Question:

I have a .ttf in my script. It looks like this:

$font = imageloadfont("./fonts/visitor1.ttf");

then:

ImageString ($img_create, $font, 5, 2, ($text), $color);

How would i change the font size?
anyone?
Pages: 1 2 3 4