PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
poepje
Forum Newbie
Posts: 6 Joined: Fri Sep 06, 2013 11:28 pm
Post
by poepje » Fri Sep 06, 2013 11:30 pm
Hi,
the below code is my captcha i want to be able to set my own font how can i do this? and is it possible to turn this into a png image with transparancy background?
Code: Select all
<?php
session_start();
//$text = rand(1000000,9999999);
$text = rand(10000,99999);
$_SESSION["vercode"] = $text;
$height = 17;
$width = 60;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p,243,247,250);
$white = imagecolorallocate($image_p, 0, 0, 0);
$font_size = 8;
imagestring($image_p, $font_size, 5, 0, $text, $white);
imagejpeg($image_p, null,100);
?>
poepje
Forum Newbie
Posts: 6 Joined: Fri Sep 06, 2013 11:28 pm
Post
by poepje » Sat Sep 07, 2013 12:12 am
thanks i will look into it i hope i can do it because i do not know anything about php
poepje
Forum Newbie
Posts: 6 Joined: Fri Sep 06, 2013 11:28 pm
Post
by poepje » Sat Sep 07, 2013 2:55 am
tried some things but i don't get it, if someone can give me the good code of how it need to be, i have my own font "106beats.ttf" i don't know about php so probably impossible for me to fix it myself
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sat Sep 07, 2013 3:28 am
What code do you have and what's not working?
poepje
Forum Newbie
Posts: 6 Joined: Fri Sep 06, 2013 11:28 pm
Post
by poepje » Sat Sep 07, 2013 3:40 am
already deleted the faulty code. I'am not able to do this myself i do not know ANYTHING about php, is like speaking Chineese to me
poepje
Forum Newbie
Posts: 6 Joined: Fri Sep 06, 2013 11:28 pm
Post
by poepje » Sat Sep 07, 2013 4:06 am
Code: Select all
<?php
session_start();
//$text = rand(1000000,9999999);
$text = rand(10000,99999);
$_SESSION["vercode"] = $text;
$height = 17;
$width = 60;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p,243,247,250);
$white = imagecolorallocate($image_p, 0, 0, 0);
$font_size = 8;
$font = '106beats.ttf';
imagestring($image_p, $font_size, 5, 0, $text, $white, $font);
imagejpeg($image_p, null,100);
?>
captcha dissapears
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sat Sep 07, 2013 6:57 am
Well you're not using imagettftext(), that's definitely a problem.
Try writing that code again and when (if) it doesn't work, don't delete the code but post it here so we can see what's wrong.
poepje
Forum Newbie
Posts: 6 Joined: Fri Sep 06, 2013 11:28 pm
Post
by poepje » Sat Sep 07, 2013 7:49 am
try writing the code again, lol i can't write php, i do not know any php, this is not made by me that's why i came here trying to get it done