Amy1980 Posted December 30, 2006 Share Posted December 30, 2006 Hello. I have small and cool guestbook script. I want to add image verification but I don't know how.Could anybody help? Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/ Share on other sites More sharing options...
noobstar Posted December 30, 2006 Share Posted December 30, 2006 What do you mean by image verification ??? Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149837 Share on other sites More sharing options...
Orio Posted December 30, 2006 Share Posted December 30, 2006 It's called captcha.Google: http://www.google.com/search?hl=en&lr=&q=captcha+phpOrio. Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149838 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 Thank You Orio. Before I read documentation I got question. Can I include captcha to my guestbook's form? or is it any problem? Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149860 Share on other sites More sharing options...
Philip Posted December 30, 2006 Share Posted December 30, 2006 You can include it on any form :) Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149875 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 Thx. I did it. But I can't see code;] Must to try;] Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149877 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 Ok. I did it. But the the captcha isin't fully integrated with my form. No matter what i write I sign the guestbook. Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149903 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 You'll need to post the code. Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149906 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 Ok. Here You are:form.php[code]<form method="post" name="guestform"> Name * <input name="txtName" type="text" id="txtName" size="30" maxlength="30"> Email <input name="txtEmail" type="text" id="txtEmail" size="30" maxlength="50"> Website URL <input name="txtUrl" type="text" id="txtUrl" value="http://" size="30" maxlength="50"> Message * <textarea name="mtxMessage" cols="80" rows="5" id="mtxMessage"></textarea> <img src="http://michael-schenker.com/modules/guestbook/library/CaptchaSecurityImages.php?character=5" style="height:30px; width:150px;"/><br /> Security Code: <input id="security_code" name="security_code" type="text" /><br /><input type="submit" name="submit" onClick="return checkForm();"/><?php session_start(); if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) { echo 'OK';// Insert you code for processing the form here } else { echo 'BAD'; // Insert your code for showing an error message here }?>[/code]Captcha.php[code]<?phpsession_start();/** File: CaptchaSecurityImages.php* Author: Simon Jarvis* Copyright: 2006 Simon Jarvis* Date: 03/08/06* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version.* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html**/class CaptchaSecurityImages { var $font = 'monofont.ttf'; function generateCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } function CaptchaSecurityImages($width='120',$height='40',$characters='6') { $code = $this->generateCode($characters); /* font size will be 75% of the image height */ $font_size = $height * 0.75; $image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream'); /* set the colours */ $background_color = imagecolorallocate($image, 255, 255, 255); $text_color = imagecolorallocate($image, 20, 40, 100); $noise_color = imagecolorallocate($image, 100, 120, 180); /* generate random dots in background */ for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } /* generate random lines in background */ for( $i=0; $i<($width*$height)/150; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } /* create textbox and add text */ $textbox = imagettfbbox($font_size, 0, $this->font, $code); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code); /* output captcha image to browser */ imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; }}$width = isset($_GET['width']) ? $_GET['width'] : '120';$height = isset($_GET['height']) ? $_GET['height'] : '40';$characters = isset($_GET['characters']) ? $_GET['characters'] : '6';header('Content-Type: image/jpeg');$captcha = new CaptchaSecurityImages($width,$height,$characters);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149940 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 right off, your session_start() needs to go first. before <!DOCTYPE, before <html> at the very top of the document. Also, you haven't included the code that actually inserts information into your guest book. That's the magic part that needs to go here: "insert your code for processing the form here."hope that makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149947 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 [quote author=michaellunsford link=topic=120378.msg493779#msg493779 date=1167509260]right off, your session_start() needs to go first. before <!DOCTYPE, before <html> at the very top of the document. Also, you haven't included the code that actually inserts information into your guest book. That's the magic part that needs to go here: "insert your code for processing the form here."hope that makes sense.[/quote]What exacly needs to be included here? Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149958 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 the part of your source code that actually puts the guest book entry into the guest book goes there. Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149969 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 hmm...I inserted the query inserting the input to database but with no success. Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149978 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 is that query also someplace else, outside the if and else statements? Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149983 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 :-[I edit file that doesn't need to be edited. I think it works now. Thanks for help Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-149987 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 Next question;)Jow to put in MySQL user broswer? [HTTP_USER_AGENT] Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-150054 Share on other sites More sharing options...
Amy1980 Posted December 30, 2006 Author Share Posted December 30, 2006 hmm.. I think everything is ok, but I get error:[code]Error, query failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(Windows; U; Windows NT 5.1; pl; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1, cur' at line 1[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32277-image-verification/#findComment-150063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.