slpctrl Posted September 5, 2008 Share Posted September 5, 2008 Alright, LAST QUESTION about my captcha, I promise (my PHP is coming back to me well ) Anyways, here are my files: <?php session_start(); $str1 = md5(microtime() * mktime()); $str = substr($str1,0,5); $captcha = imagecreatefrompng("./captcha.png"); $black = imagecolorallocate($captcha,0,0,0); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imageline($captcha,rand(50,200),rand(0,100),rand(50,200),rand(80,200),$black); imageline($captcha,rand(50,250),rand(0,100),rand(0,200),rand(50,200),$black); imageline($captcha,rand(70,150),rand(0,100),rand(50,200),rand(0,200),$black); imageline($captcha,rand(20,150),rand(0,100),rand(20,150),rand(35,200),$black); imageline($captcha,rand(80,200),rand(0,100),rand(50,200),rand(85,200),$black); imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$black); imagestring($captcha,rand(1,5),rand(0,100),rand(0,50),$str,$black); $_SESSION['str'] = md5($str); header("Content-type: image/png"); imagepng($captcha); ?> That's to create the image, and then I have the form and checker here: <?php session_start(); echo <<<HTML <html> <head> <title>Captcha</title> </head> <body> <img src="captcha.php" border="0"> <form action="" method="post"> Enter the text from the image:<br><input type="text" name="code" /> <input type="submit" /> </form> </body> </html> HTML; if(!$_POST['code']) die(); else { if(md5($_POST['code']) != $_SESSION['str']) die("Error: Wrong code entered"); else echo("Correct!"); } ?> Now, in the form I want to add a button that will only refresh the image, not the whole page. How would I go about this? Also, since I'm here how would I also go about changing the font size? Is this possible? Link to comment https://forums.phpfreaks.com/topic/122920-image-reload-question/ Share on other sites More sharing options...
micmania1 Posted September 5, 2008 Share Posted September 5, 2008 You would need to use javascript to change the source of the image. Link to comment https://forums.phpfreaks.com/topic/122920-image-reload-question/#findComment-634858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.