comptech520
11-18-2007, 03:49 PM
On my website contact form, the CAPTCHA image does not change. GD Is installed, but still nothing.
Does anyone know how to fix this?
Does anyone know how to fix this?
|
Click to See Complete Forum and Search --> : CAPTCHA image does not change comptech520 11-18-2007, 03:49 PM On my website contact form, the CAPTCHA image does not change. GD Is installed, but still nothing. Does anyone know how to fix this? knowj 11-18-2007, 03:50 PM have you tried clearing your cashe? You may not have set the correct headers to stop the image from cashe. Please post your script otherwise no one can help comptech520 11-18-2007, 03:51 PM these are my headers <META http-equiv=pragma content=no-cache> <META http-equiv=EXPIRES content=-1> <META http-equiv=Content-Type content="text/html; charset=UTF-8"> <META http-equiv=imagetoolbar content=no> knowj 11-18-2007, 03:55 PM // send several headers to make sure the image is not cached // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); Again if you posted your code it would help. sridhar_423 11-18-2007, 03:56 PM I never worked on this before.. You might get some useful information from bokeh's signature.. check it .. bokeh 11-18-2007, 05:19 PM these are my headers <META http-equiv=pragma content=no-cache> <META http-equiv=EXPIRES content=-1> <META http-equiv=Content-Type content="text/html; charset=UTF-8"> <META http-equiv=imagetoolbar content=no>Those are not headers, they are meta elements and not related to the fetching of the captcha image in any way. To force an update the easiest way is to give your captcha image a new and unique query string on every load. comptech520 11-18-2007, 05:36 PM Here is the image code file. Can you please tink with it? bokeh 11-19-2007, 03:36 AM Here is the image code file.I can't see how that is related to your question. Have you tried what I said about query string? Here's a working example (http://bokehman.com/simple_captcha.php) and here is the code (self contained; runs out of the box):<?php session_start(); # Start a session to hold the captcha code if(isset($_GET['i'])) { # image creation section captcha_image(); } elseif(isset($_POST['captcha'])) { # validation section echo(captcha_validate()?'That was correct.':'That was not correct.'); echo '<br><a href="http://'.$_SERVER['HTTP_HOST'].htmlentities($_SERVER['PHP_SELF']).'">Try another?</a>'; die; } else { # form section $self = 'http://'.$_SERVER['HTTP_HOST'].htmlentities($_SERVER['PHP_SELF']); $uid = uniqid(); echo <<<END <p> <a href="{$self}" onclick="document.getElementById('captcha').src='{$self}?i=' + new Date; return false;" >Give me an easier one!</a> </p> <p> <img id="captcha" src="{$self}?i={$uid}" alt="captcha image"> </p> <form action="{$self}" method="POST"> <p> <input type="text" name="captcha" > <input type="submit" value="test it"> </p> </form> END; } function captcha_validate() { if($_POST['captcha'] === $_SESSION['captcha']) # must use identicality, not equality. { $_SESSION['captcha'] = null; # Stops reuse return true; } return false; } function captcha_image($length = 8) { # creates a very simple captcha image just for demonstration purposes $fontsize = 5; $_SESSION['captcha'] = substr(base64_encode(md5(rand())), 0, $length); $image = imagecreate(($length*imagefontwidth($fontsize))+1, imagefontheight($fontsize)+1); $background_colour = imagecolorallocate($image, 255,255,255); $text_shadow = imagecolorallocate($image, 127,127,127); $text_colour = imagecolorallocate($image, 0,0,0); imagestring($image, $fontsize, 1, 1, $_SESSION['captcha'], $text_shadow); imagestring($image, $fontsize, 0, 0, $_SESSION['captcha'], $text_colour); header ('Content-type: image/png'); imagepng($image); imagedestroy($image); die; } ?> comptech520 11-19-2007, 06:40 AM This is what I run into. I bought a form maker package. I DON'T like the templates that came with is, and I can't modify them easliy. The original form is located http://esctonline.com/servlet/index.php?fid=1 Then I copied the HTML from the original form and put it here http://www.esctonline.com/contact.php When you refresh the servlet one, the CAPTCHA refreshes easily. When you load or refresh the contact.php form, the image stays the same or is black. knowj 11-19-2007, 08:10 AM This is what I run into. I bought a form maker package. I DON'T like the templates that came with is, and I can't modify them easliy. The original form is located http://esctonline.com/servlet/index.php?fid=1 Then I copied the HTML from the original form and put it here http://www.esctonline.com/contact.php When you refresh the servlet one, the CAPTCHA refreshes easily. When you load or refresh the contact.php form, the image stays the same or is black. I would never invest in any products like form maker packages in my personal opinion there a waste of money. They best thing you can invest in is your time and some decent books, web browsing time. Do tutorials, ask for help here when you get stuck and you will be writing your own stuff without thinking about it before you know it. If you saw the things i was having problems with 3 years ago you would laugh. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |