Jump to content

Image reload question


slpctrl

Recommended Posts

Alright, LAST QUESTION about my captcha, I promise  :D (my PHP is coming back to me well :P) 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.