img src到php文件无效

时间:2015-10-16 16:53:36

标签: php

我正在尝试使用验证码脚本,所以这是我想要的表单:

<form action="index.php?s=validate" method="post">
Enter Image Text
<input name="captcha" type="text">
<img src="captcha.php" /><br>
<input name="submit" type="submit" value="Submit">
</form>

captcha.php文件:

<?php
session_start();
$code=rand(1000,9999);
$_SESSION["code"]=$code;
$im = imagecreatetruecolor(50, 24);
$bg = imagecolorallocate($im, 22, 86, 165);
$fg = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
imagestring($im, 5, 5, 5,  $code, $fg);
header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

我很确定问题是<img src="captcha.php" /><br>,但我无法弄明白。怎么了?我从这一切得到的只有:image not showing

0 个答案:

没有答案