Kristian_C Posted September 5, 2007 Share Posted September 5, 2007 Well here's the code : <?$tittel = $_GET['tittel'];$font_storrelse = 12;$tekst_farge = imagecolorallocate (99, 99, 99);$bilde = imagecreatefromjpeg("images/button_01.jpg");imagestring($bilde, $font_storrelse, rand(5,5), rand(3,3), $tittel, $tekst_farge);header("Content-type: image/jpg");imagepng($bilde,'',80);?> Think the code is pretty wrong .. So help pleace? ..The reason for text create on image is becouse i want to use php buttons =)...-Kristian_C Link to comment Share on other sites More sharing options...
vijay Posted September 5, 2007 Share Posted September 5, 2007 Hi.. try to look at ur code: in that u r creating jpeg image and use png in header do the "imagejpeg($bilde,'',80);" instead of ur last line.. <?$tittel = $_GET['tittel'];$font_storrelse = 12;$tekst_farge = imagecolorallocate (99, 99, 99);$bilde = imagecreatefromjpeg("images/button_01.jpg");imagestring($bilde, $font_storrelse, rand(5,5), rand(3,3), $tittel, $tekst_farge);header("Content-type: image/jpg");imagepng($bilde,'',80);?> Regards,Vijay Link to comment Share on other sites More sharing options...
Guest westmatrix99 Posted September 5, 2007 Share Posted September 5, 2007 Use this:This part goes right at the top of page. <?php session_start();if(isset($_POST['subbutton'])){ //name your button for this to workif ($_POST['vercode'] != $_SESSION['vercode'] OR $_SESSION['vercode']=='') {$error = '<strong><font color="#FF0000">Incorrect verification code.</font></strong><br>';//add the above error message next to the vercode textbox with the echo tag.} else {//process the form or whatever you want}}?> The captcha.php page: <?session_start();$text = rand(10000,99999);$_SESSION["vercode"] = $text;$height = 25;$width = 65;$image_p = imagecreate($width, $height);$black = imagecolorallocate($image_p, 0, 0, 0);$white = imagecolorallocate($image_p, 255, 255, 255);$font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white);imagejpeg($image_p, null, 80);?> Save it as captcha.php and call it in an image tag on your page like this: <img src="captcha.php" id="image"alt="Code" /> If you are using this for captcha purposes.CheersWest================ Well here's the code :<?$tittel = $_GET['tittel'];$font_storrelse = 12;$tekst_farge = imagecolorallocate (99, 99, 99);$bilde = imagecreatefromjpeg("images/button_01.jpg");imagestring($bilde, $font_storrelse, rand(5,5), rand(3,3), $tittel, $tekst_farge);header("Content-type: image/jpg");imagepng($bilde,'',80);?> Think the code is pretty wrong .. So help pleace? ..The reason for text create on image is becouse i want to use php buttons =)...-Kristian_C Link to comment Share on other sites More sharing options...
Kristian_C Posted September 5, 2007 Author Share Posted September 5, 2007 Sorry westmatrix99, but it aint a vertification thing im trying to create, its a button ... ok, Vijay, now ive changed the last line to jpeg, but my text dont show :s... tried different color codes but dont work :s <?php$tittel = $_GET['tittel'];$font_storrelse = 12;$tekst_farge = imagecolorallocate (ff, ff, ff);$bilde = imagecreatefromjpeg("images/button_01.jpg");imagestring($bilde, $font_storrelse, rand(5,5), rand(3,3), $tittel, $tekst_farge);header("Content-type: image/jpg");imagejpeg($bilde,'',80);?> Link to comment Share on other sites More sharing options...
justsomeguy Posted September 5, 2007 Share Posted September 5, 2007 You're trying to use hex codes with imagecolorallocate. That function takes integer RGB values, not hex codes. The integer value of 0xFF is 255. Link to comment Share on other sites More sharing options...
bluetoother Posted September 12, 2007 Share Posted September 12, 2007 can i use these functions to generate images instead of captcha Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2007 Share Posted September 12, 2007 You use the functions to generate or modify images only. A captcha is just an image. You can read through the image reference, look through the function list to get an idea about what it can do, click on whatever functions you want to learn more about.http://www.php.net/manual/en/ref.image.php Link to comment Share on other sites More sharing options...
bluetoother Posted September 13, 2007 Share Posted September 13, 2007 i want to learn how to write an image via PHP codei want to use it instead of captcha imagesi saw that page that contain the image functionsbut i need to read some tutorial to know which functions to use Link to comment Share on other sites More sharing options...
justsomeguy Posted September 13, 2007 Share Posted September 13, 2007 You start with something like imagecreatetruecolor or imagecreatefrompng and go from there, there are functions you can use to set colors, draw lines or shapes, write text, etc, it just depends what you want to do. Check the reference for the imagecreate functions to see that, or check something like the imagestring reference to get an example of how to create an image and write text in it.http://www.php.net/manual/en/function.imagestring.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.