? php
$nama=trim($_POST['nama_komentar']);
$komentar=trim($_POST['isi_komentar']);
if (empty($nama)){echo "Anda belum mengisikan NAMA<br /><a
href=javascript:history.go(-1)><b>Ulangi Lagi</b>";}
elseif (empty($komentar)){echo "Anda belum mengisikan KOMENTAR<br
/><a href=javascript:history.go(-1)><b>Ulangi
Lagi</b>";}
elseif (strlen($komentar) > 1000){echo "KOMENTAR Anda terlalu panjang
(max 1000 char)<br /><a
href=javascript:history.go(-1)><b>Ulangi Lagi</b>";}
else{}
? >
CAPTCA.PHP
< ? php
session_start();
header("Content-type: image/png");
$captcha_image = imagecreatefrompng("ypathicon/captcha.png");
$captcha_font = imageloadfont("ypathicon/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);
? >
==============================================================
< ? php
//Form komentar
$materi="berita";
$idberita="B1108001";
$iddata=$idberita;
echo "<br /><br /><b>Isi Komentar Anda :</b>
<table width='100%' style='border: 1pt dashed #0000CC;padding: 10px;'>
<form name='form' action='?' method='POST' onSubmit='return validasi(this)'>
<input type='hidden' name='iddata' value='$iddata'>
<tr><td>Nama
</td><td> : <input type='text' name='nama_komentar'
size='25'></td></tr>
<tr><td>Email
</td><td> : <input type='text' name='email_komentar'
size='50' maxlength='50'></td></tr>
<tr><td valign=top>Komentar
</td><td> <textarea name='isi_komentar' style='width:
300px; height: 100px;'></textarea></td></tr>
<tr><td>
</td><td> <img
src='captcha.php'></td></tr>
<tr><td> </td><td> (Masukkan 6 kode diatas)<br />
<input
type='text' name='kodecaptcha' size='6' maxlength='6'><br
/></td></tr>
<tr><td>
</td><td> <input type='submit' name='Kirim'
value='Kirim'></td></tr>
</form></table><br />";
?>
< ? php
if(!empty($_POST['kodecaptcha'])){
if($_POST['kodecaptcha']==$_SESSION['captcha_session']){
$nama_komentar=trim($_POST['nama_komentar']);
$isi_komentar=trim($_POST['isi_komentar']);
$email_komentar=trim($_POST['email_komentar']);
if (empty($nama_komentar)){echo "Maaf, Anda belum mengisikan
Nama Anda...<br /><a
href=javascript:history.go(-1)><b>Ulangi Lagi</b>";}
elseif (empty($komentar)){echo "Anda belum mengisikan
Komentar Anda <br /><a
href=javascript:history.go(-1)><b>Ulangi Lagi</b>";}
elseif (strlen($komentar) > 1000){echo "Maaf, KOMENTAR
Anda terlalu panjang (max 1000 char)<br /><a
href=javascript:history.go(-1)><b>Ulangi Lagi</b>";}
else{
//SIMPAN KOMENTAR
}
}
else{
echo"<script>alert('Maaf, Kode Captcha Anda salah...Silakan cek kembali...');
document.location.href='javascript:history.go(-1)';</script>";
}
}
else{
echo"<script>alert('Silakan isi Kode Captcha Anda...Atau Silakan cek kembali...');
document.location.href='javascript:history.go(-1)';</script>";
}
?
izin berkunjung dan izin nyimak gan. Kunjungi balik ya http://goo.gl/Dpt6t0
ReplyDeleteWah, informasi yang bermanfaat & terima kasih atas informasinya...
ReplyDeleteIde Bisnis Rumahan