<?php
session_start();
?>
<form action="" method="post">
<table width="407" style='border: 1pt dashed #0000CC;padding: 10px;'>
<tr>
<td>Input Kode
<td>
<td><img src="setcaptcha.php"></td>
</tr>
<tr>
<td>
<td>
<td>
<input type="text" name="kodecaptcha" size="6" maxlength="6">
(Masukkan 6 kode diatas)
</td>
</tr>
<tr>
<td>
<td>
<td><input name="Simpan" type="submit" id="Simpan" value="Simpan" />
</td></tr>
</table>
</form>
<?php
if(isset($_POST["Simpan"])){
if($_POST["kodecaptcha"]==$_SESSION["captcha_session"]){
echo"<h1>Sukses Simpan....</h1>";
}
else{
echo"<h1>Gagal Simpan....</h1>";
}
}
?>
+++++++++++++++++++
<?php
session_start();
header("Content-type: image/png");
$captcha_image = imagecreatefrompng("captcha.png");
$captcha_font = imageloadfont("font.gdf");
$captcha_text = substr(md5(uniqid('')),-6,6);
$_SESSION['captcha_session'] = $captcha_text;
$captcha_color = imagecolorallocate($captcha_image,0,0,0);
imagestring($captcha_image,$captcha_font,15,5,$captcha_text,$captcha_color);
imagepng($captcha_image);
imagedestroy($captcha_image);
?>
Tidak ada komentar:
Posting Komentar